Re: Strange server socket behaviour



"Mike Blake-Knox" <mikebk@xxxxxxxxxxxxx> ha scritto nel messaggio news:VA.000000a3.061bda9b@xxxxxxxxxxxxxxxx

I'm fearing this, too :-(

What shows up on the server console when you run your test? You are
writing some extra information onto the console.

My error-checking code catches the SocketException in Receive(), closes the new socket and discards the client connection. Then, it tries to do serversocket.BeginAccept() again... and this, too, throws an exception!

Also, it looks as if the code accepts a connection and waits for the
first data to be received before it re-primes the accept. I think I
know (from looking at logs from a server in an unfreindly environment)
that it is possible to get exceptions from an EndAccept(). Where is the
exception taken? The sample code doesn't include the try/catch code.

Because it was sample code :-)
In the actual code, every socket method call is checked for exceptions, of course.


Massimo

.



Relevant Pages

  • Re: An existing connection was forcibly closed by the remote host...
    ... EndReceivewill throw "Can't access disposed object" exception whenever the connection is terminated. ... In MS .NET Socket implementation there is no mechanism for the socket object to signal to the main thread that it is about to be disposed. ... public Socket ClientSocket ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: "invalid handle", sockets, threads and garbage collector
    ... your IntPtr value happens to coincide with a reference. ... The exception contains "invalid handle" message. ... Socket constructor problem ... finalization means closing the handle to resource. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: reconnect tcp
    ... instance throws a fatal exception, ... to close the socket and reconnect. ... public ClientHandler(Socket client, int timeout) ... while (rxDataCounter < receiveBytes) ...
    (microsoft.public.dotnet.languages.csharp)
  • "invalid handle", sockets, threads and garbage collector
    ... The exception contains "invalid handle" message. ... Socket constructor problem ... finalization means closing the handle to resource. ...
    (microsoft.public.dotnet.framework.clr)
  • SMTP Virtual Server in IIS V5.1
    ... Exception Details: System.Net.Sockets.SocketException: No connection could ... Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState ... state, IAsyncResult asyncResult, Int32 timeout, Exception& exception) +421 ... System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String ...
    (microsoft.public.windowsxp.general)