Can I pass sockets to different threads?
Hallo, I am writing a client/server program and I am having troubles passing sockets among classes.
Basically, the client connects to a login manager, which checks credentials and then passes the socket to another class for further communication.
If i close the DataInputStream and the DataOutputStream, I get a "socket closed" exception when i try to open new ones in the "other" class (although I did not close the socket itself), whereas if I do not close the streams, I get a EOFException. :confused:
Maybe my login thread closes the socket when it dies, even though that socket is referenced in another thread?
I am starting to think that it is not possible to achieve what I was trying to do and that I'd need to open a new socket, but I'd rather not if possible so please let me know if it can be done...