开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜