Re: roburst network programming, tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp , SocketOptionName.KeepAlive , 1);
- From: "Ryan Liu" <ad50275324@xxxxxxxxxxxx>
- Date: Mon, 17 Jul 2006 01:24:07 +0800
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:and
It is very ofter on server side log I see network problem for both read
machine.write to network stream, like:
Unable to write data to the transport connection.
An established connection was aborted by the software in your host
roburst
Read System.InvalidOperationException: Operation not allowed on
non-connected sockets.
Can someone tell me what will cause the problem and how to write a
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
.
- References:
- Prev by Date: problem in uploading
- Next by Date: Re: C# versus VB.Net
- Previous by thread: Re: roburst network programming, tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp , SocketOptionName.KeepAlive , 1);
- Next by thread: Regarding creating hyperlink in C#.net
- Index(es):
Relevant Pages
|