G
Guest
Hi all,
I am testing how well my server application is connecting to multiple
clients and give and take some information. All actions(connect, accept,
send, receive) are performed by async methods - BeginXXX() and callbacks - in
both server and client sides.
As I increase the number of client connections more than 230, I am getting
socket exception: 10054(An existing connection was forcibly closed by the
remote host) in server application. What was happening was, for that
unsuccessful connections, connections seems to be established well then it's
calling BeginRead() where the exception is being thrown..
Any ideas? How can I decide if it's a performance issue?
Bob
<server side>
ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
ClientSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, true);
ClientSocket.Bind(endpoint);
ClientSocket.BeginConnect(ClientIPAddress,
Properties.Settings.Default.ListenPort,
new AsyncCallback(ConnectCallback), myState);
<client side>
// StartListen() function
listener = new TcpListener(IPAddress.Parse(IP), port);
listener.Start(3000);
listener.BeginAcceptSocket(new AsyncCallback(DoAcceptSocketCallback),
listener);
// DoAcceptSocketCallback() function
TcpListener listener = (TcpListener)ar.AsyncState;
Socket soc = listener.EndAcceptSocket(ar);
listener.BeginAcceptSocket(new AsyncCallback(DoAcceptSocketCallback),
listener);
soc.BeginReceive(rxBuf, rxOffset, rxBuf.Length - rxOffset, SocketFlags.None,
new AsyncCallback(ReadCallback), conn);
I am testing how well my server application is connecting to multiple
clients and give and take some information. All actions(connect, accept,
send, receive) are performed by async methods - BeginXXX() and callbacks - in
both server and client sides.
As I increase the number of client connections more than 230, I am getting
socket exception: 10054(An existing connection was forcibly closed by the
remote host) in server application. What was happening was, for that
unsuccessful connections, connections seems to be established well then it's
calling BeginRead() where the exception is being thrown..
Any ideas? How can I decide if it's a performance issue?
Bob
<server side>
ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream,
ProtocolType.Tcp);
ClientSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReuseAddress, true);
ClientSocket.Bind(endpoint);
ClientSocket.BeginConnect(ClientIPAddress,
Properties.Settings.Default.ListenPort,
new AsyncCallback(ConnectCallback), myState);
<client side>
// StartListen() function
listener = new TcpListener(IPAddress.Parse(IP), port);
listener.Start(3000);
listener.BeginAcceptSocket(new AsyncCallback(DoAcceptSocketCallback),
listener);
// DoAcceptSocketCallback() function
TcpListener listener = (TcpListener)ar.AsyncState;
Socket soc = listener.EndAcceptSocket(ar);
listener.BeginAcceptSocket(new AsyncCallback(DoAcceptSocketCallback),
listener);
soc.BeginReceive(rxBuf, rxOffset, rxBuf.Length - rxOffset, SocketFlags.None,
new AsyncCallback(ReadCallback), conn);