R
Ryan Liu
Hi,
I use
Server:
Use an endless thread to lisiten to clients requests:
while(true)
{
TcpClient client = myListener.AcceptTcpClient();
....
}
Client:
tcpClient = new TcpClient(host,port);
stream =tcpClient.GetStream();
....
to build a client/server application, then both server and clients start
another endless thread to receive messages from each other, and use yet
other threads to send response to each other, or server pass messages from
one client to another.
Now about 60 workstations connect to one server, all in the same local LAN.
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?
And do I have set this on both client and server side? And is this the right
way to use it:
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp ,
SocketOptionName.KeepAlive , 1);
Thanks a lot!
Ryan
I use
Server:
Use an endless thread to lisiten to clients requests:
while(true)
{
TcpClient client = myListener.AcceptTcpClient();
....
}
Client:
tcpClient = new TcpClient(host,port);
stream =tcpClient.GetStream();
....
to build a client/server application, then both server and clients start
another endless thread to receive messages from each other, and use yet
other threads to send response to each other, or server pass messages from
one client to another.
Now about 60 workstations connect to one server, all in the same local LAN.
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?
And do I have set this on both client and server side? And is this the right
way to use it:
tcpClient.Client.SetSocketOption(SocketOptionLevel.Tcp ,
SocketOptionName.KeepAlive , 1);
Thanks a lot!
Ryan