Hi Francois, Probably am.
Thing is, the server is ultimately going to be written in GCC running on Redhat 6.2 Linux. Since this appears to be a server issue perhaps it will go away then. But the fact that the two windows applications don't do the connection thing correctly tells me there is something wrong. The real question is still what? Thanks, John Dammeyer > > Why don't you use TWSocketServer ? > Are you reinventing the wheel ? > > -- > [EMAIL PROTECTED] > http://www.overbyte.be > > ----- Original Message ----- > From: "John Dammeyer" <[EMAIL PROTECTED]> > To: "'ICS support mailing'" <twsocket@elists.org> > Sent: Wednesday, October 12, 2005 8:00 PM > Subject: [twsocket] Error 10048 in TWSocket > > > > Hi all, > > > > I have a server and a client. The Server application is > started and does > > the following: > > > > SrvSocket.Proto := 'tcp'; > > SrvSocket.Addr := '0.0.0.0'; // Use any interface > > SrvSocket.Port := '4000'; // Wait on this port. > > SrvSocket.Listen; // Start listening for client > > > > I then start up the client which does this: > > > > CliSocket.Proto := 'tcp'; > > CliSocket.Addr := HostnameEdit.Text; > > CliSocket.Port := '4000'; > > CliSocket.LocalPort := '4001'; > > CliSocket.Connect; > > > > So far so good. When the connection is established the > server shows this: > > > > { We need to accept the client connection } > > NewHSocket := SrvSocket.Accept; > > > > { And then associate this connection with our client socket } > > CliSocket.Dup(NewHSocket); > > > > { Wants to know who is connected to display on screen } > > CliSocket.GetPeerName(PeerName, Sizeof(PeerName)); > > > > { User likes to see internet address in dot notation } > > Peer := IntToStr(ord(PeerName.sin_addr.S_un_b.s_b1)) + '.' + > > IntToStr(ord(PeerName.sin_addr.S_un_b.s_b2)) + '.' + > > IntToStr(ord(PeerName.sin_addr.S_un_b.s_b3)) + '.' + > > IntToStr(ord(PeerName.sin_addr.S_un_b.s_b4)); > > InfoLabel.Caption := 'Remote ' + Peer + ' connected. Port:' + > > CliSocket.GetPeerPort; > > > > And then the Server can send information to the client. > > > > m.Attrib := REVERSE_TEXT; > > m.Cmd := ATTRTEXT_CMD; > > CliSocket.Send(@m,sizeof(m)); > > > > The problem come with disconnecting and reconnecting. > > If I disconnect the server first by: > > > > { Server Application: Shutdown Server } > > CliSocket.ShutDown(SD_BOTH); { Shut the > communication down > > } > > CliSocket.Close; { Close the > communication > > } > > SrvSocket.ShutDown(SD_BOTH); { Shut the > communication down > > } > > SrvSocket.Close; { Close the > communication > > } > > > > And then shut down the client: > > > > { Client Application: Shut down client } > > CliSocket.ShutDown(SD_BOTH); { Shut the > communication down > > } > > CliSocket.Close; > > > > I can easily reconnect without problems. > > > > However if I run the Client shutdown code first (or > terminate the client > > application and restart) and shutdown the server code last, > I get the > > Error > > 10048 which is 'Port in use'. That implies (since the > client application > > is > > terminated and restarted), that the server application > seems to be hanging > > onto the port. > > > > How do I code it so either side can 'crash', be rebooted or just > > disconnect > > and reconnect? > > > > Thanks, > > > > John Dammeyer > > > > -- > > To unsubscribe or change your settings for TWSocket mailing list > > please goto http://www.elists.org/mailman/listinfo/twsocket > > Visit our website at http://www.overbyte.be > > -- > To unsubscribe or change your settings for TWSocket mailing list > please goto http://www.elists.org/mailman/listinfo/twsocket > Visit our website at http://www.overbyte.be > > -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be