I don't think you can do that. I may be wrong here regarding U2 socket functions, but it looks like you are trying to use recursive code calls which produces overlapping server listen() and bind() calls. I can only assume that error code 35 is a 10035 windows socket error, which is WSAEWOULDBLOCK and not 10048 WSAEADDRINUSE (address already in use). That probably means the guts of U2 have the socket functions running in non-blocking mode. The socket creation failed on pass #2 because of 10048 actually. It appears that you are stacking instances of Program A on top of each other when you should be starting a client socket handler instead. The listen() socket function uses a single server socket handle to wait for all connections and then accept() creates one new socket handle for each incoming connection. You need to pass the client handle to another process and let it do its own thing for that one connection.
You should not be rerunning the server socket creation process unless you willingly close the server socket and have to start over. It's reusable and responsible for the initial capture of all incoming connections. The client handles from accept() are not reusable. They are client specific. Hopefully I'm not way off in left field playing my own game. ---------------------------------------- Glen Batchelor IT Director All-Spec Industries phone: (910) 332-0424 fax: (910) 763-5664 E-mail: [email protected] Web: http://www.all-spec.com Blog: http://blog.all-spec.com ---------------------------------------- > -----Original Message----- > From: [email protected] [mailto:u2-users- > [email protected]] On Behalf Of George Gallen > Sent: Thursday, August 27, 2009 5:17 PM > To: U2 Users List > Subject: [U2] back to the socket problem.... > > Here's what I have: > > Program A. > does an "initserverSocket" request -> HANDLE1 > does an "acceptConneciton" request -> HANDLE2 > does a "closeSocket(HANDLE1)" > executes "phantom Program A" (to wait for another connection). > loops through > readSocket(HANDLE2) until done (connection closes) > does a "closeSocket(HANDLE2)" > processes data received > ends > > oook. > I start the system with a "phantom run Program A" > > open a telnet connection, it's accepted able to enter data (computer 1) > open a telnet connection, it's accepted able to enter data (computer 2) > open a telnet connection, it's accepted able to enter data (computer 3) > > now the strange part, if any of those connections closes, all connections > will immediately closes. > > After a little debugging, I found that when Program A restarts for the > 2nd/3rd.. time > the initserverSocket request an error 35 (already being used), I didn't > have an > error routine to trap that, so it kept on going through the program, > and it was > given a new HANDLE2 each time from the acceptConnection routine. > > here's my quandry....I have to execute initserverSocket to get a HANDLE1 > whch is > required for the acceptConnection routine, if I don't allow the program > A to > continue after the error 35 (and somehow is using a valid HANDLE1), I > won't > be able to open session 2 and session 3 until session 1 is closed. > > How does one set this up, so simultaneous connections can be made to the > SAME > port, and when one session closes, it doesn't close all sessions? > > > > _______________________________________________ > U2-Users mailing list > [email protected] > http://listserver.u2ug.org/mailman/listinfo/u2-users _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
