Solved

Multi-Threading And The Winsock

Posted on 1998-12-31
8
464 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

635 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