Home > other >  When sending data to other client Socket error: The operation is not allowed on non - connected sock
When sending data to other client Socket error: The operation is not allowed on non - connected sock

Time:09-23

Question is like this, make add buddy module, encountered a problem, is at the time of the login, the server will pass ID binding the Socket:
 
//the current online client dictionary, and ID binding
Dictionary DicOnlineClients;
,
Binding:
 
//to the current online client list add the client
DicOnlineClients. Add (playerID, packet. _peer);

Then send a friend request with this ID through this ID to bind Socket, if the client has no offline
 
//get the ID of the Socket
The Socket Socket;
If (DicOnlineClients. TryGetValue (FriendID, out socket))
{
$_server. Send (SendStream, socket);
}

But The problem is, when The Send, an error of The operation is not allowed on non - connected sockets.
But my client socket is obviously online
Please help solve the great god, or any other method, is used to specify the client sends data, here I use is by the player ID identification
  • Related