470,561 Members | 2,150 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,561 developers. It's quick & easy.

Asynchronous Sockets in .NET

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?
Jul 21 '05 #1
3 2470

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

--- Queue proc thread ----
while running
Just get queued connections and create sessions for them

------------------------

"Corne Oosthuizen" <co*********@shoprite.co.za> wrote in message
news:03****************************@phx.gbl...
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?

Jul 21 '05 #2
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.
-----Original Message-----

Don't know work ok for me.

If you want I can give you c# sample app(SMTP/POP3/IMAP server) which workok 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 queueproccessing thread which starts sessions.

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

--- Queue proc thread ----
while running
Just get queued connections and create sessions for them
------------------------

"Corne Oosthuizen" <co*********@shoprite.co.za> wrote in messagenews:03****************************@phx.gbl...
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?

.

Jul 21 '05 #3

See:
http://www.lumisoft.ee/lsWWW/Downloa...r/Devel/Async/

You can check this link for newer versions (see date), it's updated
frequently.

if you want discuss or have questions/suggestions write directly to my
email.

"Corne Oosthuizen" <co*********@shoprite.co.za> wrote in message
news:0c****************************@phx.gbl...
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.
-----Original Message-----

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

--- Queue proc thread ----
while running
Just get queued connections and create sessions for

them

------------------------

"Corne Oosthuizen" <co*********@shoprite.co.za> wrote in

message
news:03****************************@phx.gbl...
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?

.

Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Matthew King | last post: by
9 posts views Thread by Michael Lindsey | last post: by
3 posts views Thread by Corne Oosthuizen | last post: by
4 posts views Thread by taskswap | last post: by
4 posts views Thread by Macca | last post: by
4 posts views Thread by Engineerik | last post: by
2 posts views Thread by Nicolas Le Gland | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.