Solved

Multi-Threading And The Winsock

Posted on 1998-12-31
8
437 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
ID: 1453421
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
ID: 1453422
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
ID: 1453423

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
ID: 1453424
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Expert Comment

by:idcanada
ID: 1453425

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
ID: 1453426
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
ID: 1453427

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
ID: 1453428

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL400 max size 5 77
How to debug this code 7 56
Windows Script Host failed (Access is denied.) error 6 104
Way to decrease size of apk file 9 42
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

911 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

16 Experts available now in Live!

Get 1:1 Help Now