Cannot reconnect to TCP/IP server socket 
Author Message
 Cannot reconnect to TCP/IP server socket

I have a client TCP /IP application which connects on a server  at a certain
port (non blocking socket).
When the client tries to connect for the first time everything works ok. (It
sends and receives data ok)

But when I close the socket and try to reconnect the client cannot connect
to server.
The connect call  doesnt  reach the server. ( I put a breakpoint at the
server side OnAccept handler,
which breaks only at the fisrt time)

The way  I close the socket
is
 shutdown(sock, SD_BOTH);
 closesocket(sock);

and they both return success.

The client socket isnt an MFC socket. Its a class I've made. It does all the
I/O through a worker thread , that exits ok everytime I close the socket.

Any ideas , thanx in advance



Tue, 26 Apr 2005 10:13:36 GMT  
 Cannot reconnect to TCP/IP server socket
Is the server socket still 'listening'?

--
Hank Williams
Quantum Technologies, Inc.


Quote:
> I have a client TCP /IP application which connects on a server  at a
certain
> port (non blocking socket).
> When the client tries to connect for the first time everything works ok.
(It
> sends and receives data ok)

> But when I close the socket and try to reconnect the client cannot connect
> to server.
> The connect call  doesnt  reach the server. ( I put a breakpoint at the
> server side OnAccept handler,
> which breaks only at the fisrt time)

> The way  I close the socket
> is
>  shutdown(sock, SD_BOTH);
>  closesocket(sock);

> and they both return success.

> The client socket isnt an MFC socket. Its a class I've made. It does all
the
> I/O through a worker thread , that exits ok everytime I close the socket.

> Any ideas , thanx in advance



Tue, 26 Apr 2005 12:19:49 GMT  
 Cannot reconnect to TCP/IP server socket
Yes , other clients (from different application) can still connect to the
server.


Quote:
> Is the server socket still 'listening'?

> --
> Hank Williams
> Quantum Technologies, Inc.



> > I have a client TCP /IP application which connects on a server  at a
> certain
> > port (non blocking socket).
> > When the client tries to connect for the first time everything works ok.
> (It
> > sends and receives data ok)

> > But when I close the socket and try to reconnect the client cannot
connect
> > to server.
> > The connect call  doesnt  reach the server. ( I put a breakpoint at the
> > server side OnAccept handler,
> > which breaks only at the fisrt time)

> > The way  I close the socket
> > is
> >  shutdown(sock, SD_BOTH);
> >  closesocket(sock);

> > and they both return success.

> > The client socket isnt an MFC socket. Its a class I've made. It does all
> the
> > I/O through a worker thread , that exits ok everytime I close the
socket.

> > Any ideas , thanx in advance



Tue, 26 Apr 2005 12:55:16 GMT  
 Cannot reconnect to TCP/IP server socket
I that case, I would check the address and port number the client is using
(did they get corrupted?).

--
Hank Williams
Quantum Technologies, Inc.


Quote:
> Yes , other clients (from different application) can still connect to the
> server.



> > Is the server socket still 'listening'?

> > --
> > Hank Williams
> > Quantum Technologies, Inc.



> > > I have a client TCP /IP application which connects on a server  at a
> > certain
> > > port (non blocking socket).
> > > When the client tries to connect for the first time everything works
ok.
> > (It
> > > sends and receives data ok)

> > > But when I close the socket and try to reconnect the client cannot
> connect
> > > to server.
> > > The connect call  doesnt  reach the server. ( I put a breakpoint at
the
> > > server side OnAccept handler,
> > > which breaks only at the fisrt time)

> > > The way  I close the socket
> > > is
> > >  shutdown(sock, SD_BOTH);
> > >  closesocket(sock);

> > > and they both return success.

> > > The client socket isnt an MFC socket. Its a class I've made. It does
all
> > the
> > > I/O through a worker thread , that exits ok everytime I close the
> socket.

> > > Any ideas , thanx in advance



Tue, 26 Apr 2005 14:18:31 GMT  
 Cannot reconnect to TCP/IP server socket
No the object that owns the socket is destroyed , so everything is
initialized from the beginning.
I  use breakpoints and nothing seems to be corrupted.
Have I forgotten something important when I close the socket ?

Should I call WSACleanup, except shutdown and close?
Are there any other cleanups to do?


Quote:
> I that case, I would check the address and port number the client is using
> (did they get corrupted?).

> --
> Hank Williams
> Quantum Technologies, Inc.



> > Yes , other clients (from different application) can still connect to
the
> > server.



> > > Is the server socket still 'listening'?

> > > --
> > > Hank Williams
> > > Quantum Technologies, Inc.



> > > > I have a client TCP /IP application which connects on a server  at a
> > > certain
> > > > port (non blocking socket).
> > > > When the client tries to connect for the first time everything works
> ok.
> > > (It
> > > > sends and receives data ok)

> > > > But when I close the socket and try to reconnect the client cannot
> > connect
> > > > to server.
> > > > The connect call  doesnt  reach the server. ( I put a breakpoint at
> the
> > > > server side OnAccept handler,
> > > > which breaks only at the fisrt time)

> > > > The way  I close the socket
> > > > is
> > > >  shutdown(sock, SD_BOTH);
> > > >  closesocket(sock);

> > > > and they both return success.

> > > > The client socket isnt an MFC socket. Its a class I've made. It does
> all
> > > the
> > > > I/O through a worker thread , that exits ok everytime I close the
> > socket.

> > > > Any ideas , thanx in advance



Tue, 26 Apr 2005 15:15:52 GMT  
 Cannot reconnect to TCP/IP server socket
The only thing I can think of is to make sure the 'FD_CONNECT | FD_ACCEPT'
are still valid for the listening socket.
Did they get changed by 'AsyncSelect()'?  Usually when 'OnAccept()' event is
not triggered the FD_ACCEPT is missing.

I am able to reconnect as many times as needed.

--
Hank Williams
Quantum Technologies, Inc.


Quote:
> No the object that owns the socket is destroyed , so everything is
> initialized from the beginning.
> I  use breakpoints and nothing seems to be corrupted.
> Have I forgotten something important when I close the socket ?

> Should I call WSACleanup, except shutdown and close?
> Are there any other cleanups to do?



> > I that case, I would check the address and port number the client is
using
> > (did they get corrupted?).

> > --
> > Hank Williams
> > Quantum Technologies, Inc.



> > > Yes , other clients (from different application) can still connect to
> the
> > > server.



> > > > Is the server socket still 'listening'?

> > > > --
> > > > Hank Williams
> > > > Quantum Technologies, Inc.



> > > > > I have a client TCP /IP application which connects on a server  at
a
> > > > certain
> > > > > port (non blocking socket).
> > > > > When the client tries to connect for the first time everything
works
> > ok.
> > > > (It
> > > > > sends and receives data ok)

> > > > > But when I close the socket and try to reconnect the client cannot
> > > connect
> > > > > to server.
> > > > > The connect call  doesnt  reach the server. ( I put a breakpoint
at
> > the
> > > > > server side OnAccept handler,
> > > > > which breaks only at the fisrt time)

> > > > > The way  I close the socket
> > > > > is
> > > > >  shutdown(sock, SD_BOTH);
> > > > >  closesocket(sock);

> > > > > and they both return success.

> > > > > The client socket isnt an MFC socket. Its a class I've made. It
does
> > all
> > > > the
> > > > > I/O through a worker thread , that exits ok everytime I close the
> > > socket.

> > > > > Any ideas , thanx in advance



Wed, 27 Apr 2005 14:04:32 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. TCP/IP client-server aplication on sockets in C++ Builder

2. socket and tcp/ip request

3. TCP/IP sockets programming

4. TCP/IP socket programming

5. TCP/IP sockets: runtime bind() error: invalid argument

6. TCP/IP socket programming

7. porting a VC++ 4.2 tcp/ip sockets app to mac

8. tcp/ip and sockets

9. Sockets and TCP/IP newbie

10. porting a VC++ 4.2 tcp/ip sockets app to mac

11. Implementing TCP/IP and TELNET for a server software

12. C program - Unix TCP/IP Server restart

 

 
Powered by phpBB® Forum Software