Can I close ServerSocket after

Can i close the ServerSocket after it has accepted a connection and still be able to use that socket that the ServerSocket.accept() returned. heres the code for that to make a little more sense

ServerSocket PersonalSocket =new ServerSocket(ports);

ConnectList[ports - 7000] = PersonalSocket.accept();

PersonalSocket.close();

ConnectList is an array of Sockets

SO my question is will ConnectList work once PersonalSocket has been closed?

Thx for any help

[530 byte] By [Staxoa] at [2007-10-3 2:21:19]
# 1
Yes, socket from accept( ) will work fine.BTW it's very easy to simulate and check such situation - try to experiment, it's funny and very helpfull...
Michael.Nazarov@sun.coma at 2007-7-14 19:20:15 > top of Java-index,Archived Forums,Socket Programming...
# 2

> ServerSocket PersonalSocket = new

> ServerSocket(ports);

> ConnectList[ports - 7000] = PersonalSocket.accept();

> PersonalSocket.close();

>

> ConnectList is an array of Sockets

> SO my question is will ConnectList work once

> PersonalSocket has been closed?

ConnectList[] won't work at all, but not because of closing the ServerSocket. If you put all accepted sockets into the same place you are going to lose all but the last one.

ejpa at 2007-7-14 19:20:15 > top of Java-index,Archived Forums,Socket Programming...