简体   繁体   English

有没有一种方法可以唯一地标识套接字?

[英]Is there a way to uniquely identify a socket?

I'm trying to implement a simple Client/Server program in Java (mainly through the multi Client and Server tutorials provided by Oracle). 我正在尝试用Java实现一个简单的Client / Server程序(主要通过Oracle提供的Multi Client and Server教程)。

I'm just wondering if there's a way to uniquely identify a connected client on the server side? 我只是想知道是否可以在服务器端唯一地标识连接的客户端?

Yes, by the value of the Socket reference itself. 是的,通过Socket引用本身的值。

When a client connects to the server, store the Socket instance. 当客户端连接到服务器时,存储Socket实例。
Then you can use it later to identify the connected client. 然后,您可以稍后使用它来标识连接的客户端。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM