Get connection ID from ServerSocket
I need to get connection ID开发者_JAVA百科 from ServerSocket. By client I send text and I need to know which client sended text. Any ideas??
procedure Tf_serveur.ServerSocket1ClientRead(Sender: TObject;
Socket: TCustomWinSocket);
begin
Memo1.Lines.Add(Socket.RemoteAddress+'\>'+Socket.ReceiveText);``
// Socket.RemoteAddress is the client ip
// Socket.RemoteHost is the client nameposte
// Socket.receivetext is the client text sinding
end;
I am thinking that he is referring to the handle of the socket
procedure TForm1.srvrsckt1ClientConnect(Sender: TObject;
Socket: TCustomWinSocket);
var connectedClientSockHandle : Integer;
begin
connectedClientSockHandle := socket.Handle;
end;
I think what you should do is have each new connection (in the onaccept
function) assigned to a unique ID (random letters/numbers) then every command sent from client->server will contain the unique ID of that client.
精彩评论