Solved

Multi-Threading And The Winsock

Posted on 1998-12-31
8
446 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 - Compare and highlight cell not the same 3 53
Excel file not created as expected 7 79
Python 3.5.2 32 virtualenv problems 3 67
Link failure 16 35
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

831 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