By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,509 Members | 1,227 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,509 IT Pros & Developers. It's quick & easy.

Asynchronous Sockets in .NET

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a

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

P: n/a
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

P: n/a

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.