How do I close a port in a case of program termination?

前端 未结 4 1729
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 06:19

I am using Socket communication in one of my Java applications.As I know if the program meets any abnormal termination the listening ports does not get closed and the progra

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 06:58

    The operating system should handle things such as that automatically, when the JVM process has ended. There might be a short delay before the port is closed, though.

提交回复
热议问题