Generally you cannot control ports, its sort of a first come first served. If you want to listen at a port say 3306, just try and open a server socket on it, if the process of binding fails its because its already in use.
RMI runs at a specific port, and so perhaps your question is about client side sockets in which case you only need to make sure that the RMI service is running?
Assuming u want to find out if RMI is running, u cud try establishing an RMI service at that port, if it fails because of a "Refused to connect" Exception, then RMI is not running
发布评论
评论(1)
一般来说,您无法控制端口,它是先到先得的。 如果您想侦听端口(例如 3306),只需尝试在其上打开服务器套接字,如果绑定过程失败,因为它已在使用中。
RMI 在特定端口运行,因此您的问题可能是关于客户端套接字,在这种情况下您只需要确保 RMI 服务正在运行?
假设你想知道 RMI 是否正在运行,你可以尝试在该端口建立 RMI 服务,如果由于“拒绝连接”异常而失败,则 RMI 没有运行
Generally you cannot control ports, its sort of a first come first served. If you want to listen at a port say 3306, just try and open a server socket on it, if the process of binding fails its because its already in use.
RMI runs at a specific port, and so perhaps your question is about client side sockets in which case you only need to make sure that the RMI service is running?
Assuming u want to find out if RMI is running, u cud try establishing an RMI service at that port, if it fails because of a "Refused to connect" Exception, then RMI is not running