Asynchronous Sockets in .NET

  • Thread starter Corne Oosthuizen
  • Start date
C

Corne Oosthuizen

I'm writing a Telnet Server application using
Asynchronous sockets.

I spawn a listener thread to handel incomming connections
and create a separate client socket for each new
connection.

I then set the new client socket to BeginReceive().

My problem: When two client socket connections send data
at the same time, the one socket connection reads the
data from both connections and the other connection's
Recieve Callback never fires.

I first dicovered this when I ported a C# sample to VB
that used the TCPClient and TCPListener objects. I then
read in the MSDN library that these objects are for
synchronous blocking communication only. Although it
worked fine otherwise.

I then re-wrote everything from scratch using just
sockets with the MSDN Library as the only reference. I
still get this same problem.

Any Ideas?
 
I

Ivar

Don't know work ok for me.

If you want I can give you c# sample app(SMTP/POP3/IMAP server) which work
ok with asynchronous socket.

For acceptiong connection I don't suggest use BeginAccept(), on hevy load
(>100 connections/sec) clients begin to recieve connect timeout.
Use socket.Accept() and put connetion to queue, add to your server queue
proccessing thread which starts sessions.

----Accept thread Thread
while running
Accpt
put to queue
 
C

Corne Oosthuizen

Hi Ivar,

I would appreciate it if you could give me some source
code.
It would be great if I could look at an example that
actually works.

Its good to know that BeginReceive() croacks on 100
connections /s

I am busy researching using both Asynchronous and
syncronous socket connections.

Thanks.
Corne.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top