Re: Strange server socket behaviour



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



.



Relevant Pages

  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)
  • Re: ASP.NET 2.0 - a newbie question
    ... Is there some experienced ASP.NET 2.0 developer, ... server that comes bundled Microsoft VWDE. ... A connection attempt failed because the ... connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& ...
    (microsoft.public.dotnet.framework.aspnet)
  • error when move web service from dev machine to test server
    ... I have a simple web service that I developed on my laptop that resides ... test server, & when I try to run it, I get the error "No connection could be ... No connection could be made because the target machine actively refused it ... Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Messaging alert
    ... I was hopping that I could use sockets to create a connection back and forth in order to send the message. ... I want to be able to send a file name and other information thru the client socket to then process in the servers. ... fileevent $sock w ... At the server side I am listening at the port and execute Accept2 when the socket is created. ...
    (comp.lang.tcl)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ...
    (microsoft.public.win32.programmer.networks)