Solved

Multi-Threading And The Winsock

Posted on 1998-12-31
8
455 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 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…

734 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