Re: roburst network programming, tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp , SocketOptionName.KeepAlive , 1);

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Markus,

Actually I have no problem with Listener, I have problem after the
connection is made. Then the server spawn one thread for each connected
client.

Actually there is not lot of threads. Only one thread for server to listen,
and one thread in server to receive data from each client and handle it.

When one client send message to server then server pass to another client,
it only involves one thread of the first client, but 2 network streams.

Thanks,
Ryan




"Markus Stoeger" <spamhole@xxxxxx> ????
news:e1L9%23OMqGHA.2348@xxxxxxxxxxxxxxxxxxxxxxx
Ryan Liu wrote:
It is very ofter on server side log I see network problem for both read
and
write to network stream, like:

Unable to write data to the transport connection.
An established connection was aborted by the software in your host
machine.

Read System.InvalidOperationException: Operation not allowed on
non-connected sockets.

Can someone tell me what will cause the problem and how to write a
roburst
network application?

I am using TcpClient, in SDK, I see there is a method

Socket.SetSocketOption(), which can set SocketOptionName.KeepAlive

What does this mean, will this be helpful?

I don't think KeepAlives will help you (see google). You are getting the
error because you are writing to a socket whose connection has been
closed (either intentionally or because of other reasons like network
problems or a crashed server).

When calling Socket.Receive you should 1) use a try/catch block around
it and 2) check the return value. A return value of 0 means that the
connection has been closed. You should not call Send on the socket after
it returned 0 bytes or after an exception. Close and destroy it.

btw - why not use async sockets instead of starting so many threads?

hth,
Max


.



Relevant Pages

  • Re: Banana Republic (was Re: OpenVMS Book Wins award)
    ... client ... No bollocks HTTP, SOAP, XML, Java, Garbage ... receive messages from any number of server processes who in turn could be ... Unlike TCP/IP and/or UDP Sockets with Java that have been around since ...
    (comp.os.vms)
  • Re: .Net Scalability problem
    ... LoadRunner will peak out a server with a few virtual users. ... To get an idea of load, ... Fire off the test client and watch the number of ... > So I think that the MTC generate concurrent connection and per ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Connection lost at same time every hour (sometimes)
    ... After making the two following alterations on the server the problem seems ... After analyze your ipconfig on SBS and client, ... Then, other connection is good, ...
    (microsoft.public.windows.server.sbs)
  • Re: server disconnection - very often
    ... Reason of permanent popups is VMware server aplication on clients. ... Run CEICW to configure the network of SBS: ... Two network adapters - manual router connection to broadband ... Uninstall VMware on client. ...
    (microsoft.public.windows.server.sbs)
  • Re: Lan setup 2 nic
    ... The external nic only has TCP/IP enabled. ... Ipconfig of the server is looking good, but the client is still missing the ... > connection so we have a 2 nic with router setup now. ...
    (microsoft.public.windows.server.sbs)