V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
tobyxdd
V2EX  ›  Java

好好的 ServerSocket 久了会自己 Close 是什么情况......

  •  
  •   tobyxdd ·
    tobyxdd · Aug 26, 2016 · 2989 views
    This topic created in 3536 days ago, the information mentioned may be changed or developed.

    核心逻辑其实巨简单,就是

    while true:
    	try
    		socket = serverSocket.accept
    		xxxx(socket)
     		......
    	catch
    		......
    

    这样的。。然后程序跑个几小时基本没问题,然而有时更久后在有新连接进来以后 accept 居然会报 SocketClosedException 出现也没什么规律 不过有个三四次了 确认程序没有任何其他地方 close 这个 而且真关了的 ServerSocket 不是应该调用 accept 时立即爆 Exception 么 这个居然是继续阻塞着每来个新连接报一次?!

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   790 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 20:15 · PVG 04:15 · LAX 13:15 · JFK 16:15
    ♥ Do have faith in what you're doing.