Re: Strange server socket behaviour
- From: "Kevin Spencer" <unclechutney@xxxxxxxxxxxx>
- Date: Fri, 26 Jan 2007 14:52:52 -0500
I think it has to do with making a blocking call to Receive when listening
asynchronously. The .Net Framework SDK says the following in the Receive
documentation:
"If no data is available for reading, the Receive method will block until
data is available. If you are in non-blocking mode, and there is no data
available in the protocol stack buffer, the Receive method will complete
immediately and throw a SocketException. You can use the Available property
to determine if data is available for reading. When Available is non-zero,
retry your receive operation."
In fact, I've never heard of anyone attempting to combine asynchronous and
synchronous methods in the same application.
--
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
The shortest distance between 2 points is a curve.
"Massimo" <barone@xxxxxxxxx> wrote in message
news:OshAzWXQHHA.4736@xxxxxxxxxxxxxxxxxxxxxxx
"Kevin Spencer" <unclechutney@xxxxxxxxxxxx> ha scritto nel messaggio
news:OFQR41TQHHA.4276@xxxxxxxxxxxxxxxxxxxxxxx
The remote client will certainly close the connection if your client
socket does not. Take a look at the following 2 articles on using an
asynchronous server socket:
http://www.codeguru.com/csharp/csharp/cs_misc/sampleprograms/article.php/c7695/#more
http://www.codeguru.com/Csharp/Csharp/cs_network/sockets/article.php/c8781/
The following tutorial may also be of help:
http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=709
I'm sorry?
What do you exactly mean?
I already have a perfectly working server that uses asynchronous sockets
:-)
The problem is, when this particular device connects to it, the behaviour
I described surfaces. When I connect from a .NET client program, it works
flawlessly.
Why should the remote client close the connection? Its C code isn't
telling him to do this, its code says "open a connection to this server on
this port and keep it open". But when the server tries to Receive() from
the newly accepted connection, it gets that SocketException saying the
connection was closed from the remote host. It should just blocks waiting
for data, shouldn't it? It does, when a .NET client connects. This is the
reason I think there are some bugs in the device's TCP/IP libraries. But
the device can open a connection to an Internet web server, so maybe its
TCP/IP works... and there's something wrong in my server.
It's a strange problem, I agree... but I don't think a socket tutorial is
what I'm in need of :-)
Massimo
.
- Follow-Ups:
- Re: Strange server socket behaviour
- From: Massimo
- Re: Strange server socket behaviour
- From: Barry Kelly
- Re: Strange server socket behaviour
- References:
- Strange server socket behaviour
- From: Massimo
- Re: Strange server socket behaviour
- From: Kevin Spencer
- Re: Strange server socket behaviour
- From: Massimo
- Strange server socket behaviour
- Prev by Date: Re: auto email in asp.net
- Next by Date: Re: Strange server socket behaviour
- Previous by thread: Re: Strange server socket behaviour
- Next by thread: Re: Strange server socket behaviour
- Index(es):
Relevant Pages
|