Socket won't close after program is terminated

My socket won't close after my program is terminated regardless of if I use the .close method or not.
16 Replies
JavaBot
JavaBot3y ago
Hey, @Kar.Jar! Please remember to /close this post once your question has been answered!
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Carter
CarterOP3y ago
Pastebin
Server Class - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Carter
CarterOP3y ago
Pastebin
Client Class - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Carter
CarterOP3y ago
the gist of the program is that it takes in console input in the Client class and sends the message to the server and outputs a different message with the date.
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Carter
CarterOP3y ago
so basically the socket won't close the server object I created in the main method it has a ServerSocket object field
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Carter
CarterOP3y ago
a bind exception the ServerSocket is creating a connection but it's not killing it once the program ends so I can't use the same port if I end the program unexpectedly without a Bind Exception
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Carter
CarterOP3y ago
wdym I'm using try with resources, I wanted to avoid using that with the SocketServer because I want to keep it as an instance variable
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Carter
CarterOP3y ago
where can you show specifically? everything besides the ServerSocket that is reading and writing is implicitly closed with try-with-resources
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Carter
CarterOP3y ago
all good this has been a real pain but there is probably a simple fix
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server