简体   繁体   English

套接字编程服务器套接字超时

[英]Socket Programming Server Socket TimeOut

If my Server Socket has a timeout using setSoTimeOut for some 10 seconds. 如果我的服务器套接字使用setSoTimeOut超时了大约10秒钟。 Is there a way to find the ServerSocket's timeOut Property in my SocketClient ? 有没有办法在我的SocketClient中找到ServerSocket的timeOut属性? I have a situation where ServerSocket has some timeout, I need to know in my Client and i have no knowledge about how they have configured timeOut in ServerSocket 我遇到ServerSocket超时的情况,我需要在Client中知道,我不知道他们如何在ServerSocket中配置timeOut

I have a situation where ServerSocket has some timeout, I need to know in my Client 我遇到ServerSocket超时的情况,我需要在Client中知道

No you don't. 不,你不会。 The requirement is self-contradictory. 要求是自相矛盾的。 Until your client has connected to the server, it isn't a client at all, and there is no means by which it can know anything about the server whatsoever apart from its IP address and port number. 在您的客户端连接到服务器之前,它根本不是客户端,并且除了其IP地址和端口号之外,没有任何办法可以使您了解有关服务器的任何信息。

As far as I can see, you don't need to know in your client at all. 据我所知,您根本不需要了解客户。 The ServerSocket timeout operates when the accept() method has been called and there has been no inbound connection for that period. ServerSocket超时在调用accept()方法并且在此期间没有入站连接时运行。 If there is a way the client can make use of that information, you need to tell us what it is. 如果客户有办法利用这些信息,则需要告诉我们它是什么。

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

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