Solved

Multi-Threading And The Winsock

Posted on 1998-12-31
8
432 Views
Last Modified: 2013-11-13
I'm trying to write a simple Apartment-model telnet server.
I want each accepted connection on a different thread.
But, as I'm using the WinSock controls, the cloned Winsock won't accept the requestID of the Server socket because its on a different thread. Is there a way accepting connections across threads?
Does it mean I have to call the WinSock directly, instead of using the ActiveX control?
Any sample code would be appreciated.
0
Comment
Question by:LadyVyxen
8 Comments
 
LVL 2

Expert Comment

by:cedricd
Comment Utility
If you want, i can give you a program made by me and some friend for a study work.
It's a client server program using winsock (you can connect many clients to one server accessing an access DB).
I don't use multi threading because it's too slow, i use some instance of winsock :
winsock(0) for listening
winsock(1) the first client
winsock(2) second client
..
0
 

Author Comment

by:LadyVyxen
Comment Utility
No - I *really* need it to Multi-thread... I'm going to be attaching multiple instances of the Sax Basic control which *may* hang the thread. I need it so that it doesn't hang the server. Multiple instances of the Winsock control on the same thread isn't the way I want to go, as its for a Multi_user chat system compiling VBA on-the-fly. (The VBA may cause recursive loops, hence the hung thread)
0
 
LVL 4

Expert Comment

by:idcanada
Comment Utility

So sorry to inform you that if you do MultiThread, you can kiss your use of the Winsock control. Who is, by the way, multithreaded.
May I suggest you build a seperate EXE for the telnet server.
Something small that is launched by your main application.
0
 

Author Comment

by:LadyVyxen
Comment Utility
I need *each connection* on a seperate thread. I know its possible, because most C-based Web Servers are multi-threaded that way. If I need to call the winsock directly, then I will... But will someone please specify that I have to!

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 4

Expert Comment

by:idcanada
Comment Utility

As far as the lattest version of VB goes, you can NOT.
What is it with people that think they can somehow extend the Virtual Machine
or controls they are bound to.

Now, C is a whole different story, and your objective could very well be met.
For one, this is why most C-based Web Servers are written in C, not VB.

Regards.
0
 

Author Comment

by:LadyVyxen
Comment Utility
I refuse to believe that writing a Multi-threaded telnet server in VB is impossible! I *know* there is a multi-threaded VB web server available on TuCows, but its not like the owner is going to want to give up his source. :/
If the WinSock control is not an option then I'll just have to call the Winsock API directly...
0
 

Accepted Solution

by:
masuta earned 100 total points
Comment Utility

You could try using the Catalyst IP Daemon control.

-----Original Message-----
From: Jack Kemp [mailto:helpdesk@catalyst.com]
Sent: 08 January 1999 18:48
To: remi@masuta.demon.co.uk
Subject: Re: Winsock multi-threading


Hi Remi,

Yes, the controls are thread-safe, but must be single apartment threaded.

===============================================================

Jack Kemp (helpdesk@catalyst.com)

http://www.catalyst.com

Technical Support Representative

Catalyst Development Corporation      Fax: +1 818 225 5123

Empowering you to integrate the Internet into your applications!

===============================================================

>>From: MASUTA Remi <remi@masuta.demon.co.uk>
>>To: "'info@catalyst.com'" <info@catalyst.com>
>>Subject: Winsock multi-threading
>>Date: Fri, 8 Jan 1999 08:10:37 -0000
>>X-Loop-Detect: 2
>>
>>
>>I want to create a multi-threaded server application, with each connection
>>on a seperate thread. Can you tell me if your product supports such a
>>design?
>>
>>Faithfully,
>>Remi C. Masuta
>>
>>
>


0
 

Author Comment

by:LadyVyxen
Comment Utility

It looks like using a third-party server control is the way to go. I ws just looking at Distinct TCP/IP's server control - But they want either a hefty prepayment or royalties. :/

I'll take a look at Catalyst's offering now...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now