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
Hey, @Kar.Jar!
Please remember to
/close
this post once your question has been answered!can you send code?
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.
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.
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.
so the error is on client's side?
so basically the socket won't close
the server object I created in the main method
it has a ServerSocket object field
any errors?
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
its not about sockets. its about streama
streams"
you dont close them
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
you dont close DataInputStream
where
can you show specifically?
everything besides the ServerSocket that is reading and writing is implicitly closed with try-with-resources
you know what? my only tip is to puf serverSocket.close(); in try catches (error side)
otherwise sorry, but I have no idea
all good this has been a real pain but there is probably a simple fix
sockets are pain