Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ReceiveData(IAsyncResult iar)
- {
- try
- {
- StateObject stateObject = (StateObject)iar.AsyncState;
- Socket remote = stateObject.workSocket;
- int recv = remote.EndReceive(iar);
- if (recv == 0)
- {
- //remote.Close();
- try
- {
- remote.Disconnect(true);
- }
- catch
- {
- }
- finally
- {
- lock (_freeTxConnsLocker)
- {
- numberOfFreeTxConnections--;
- }
- addDebugMessageLine("TX Connection Disconnected by peer.");
- connectedTxSocketArray[((ClientSocket)remote).socketIndex] = null;
- System.Console.WriteLine("Failed " + ((ClientSocket)remote).socketIndex);
- connectionStatusArray[((ClientSocket)remote).socketIndex] = ConnectionStatus.Error;
- ((ClientSocket)remote).connected = false;
- }
- }
- else
- {
- //string stringData = Encoding.ASCII.GetString(stateObject.buffer, 0, recv);
- }
- }
- catch (Exception e)
- {
- addDebugMessageLine("Exception in TX Receive Data Method.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement