Reconnecting to a socket

G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

I have written a Winsock client/server application. When the client is
finished it issues a closesocket(). If I run it again it gets an FD_CONNECT
from the server with NetworkEvents.lNetworkEvents = 0. However, the server
never gets any events (I am expecting at least an FD_ACCEPT) .

When a connecting client disconnects from a listening server is there
something that the server should do in order to hear new connection
attempts? I have issuing bind() again (error) and listen() again() (return
code success) to no avail. The listening server never hears new connection
attempts.

Many thanks.
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Really you need graceful close ( shutdown() with closesocket() ) but even
without that if your server continue to listen for incoming connection if
have to receive accept when new one client try to
connect
Arkady

"Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
news:#tqjhHj6EHA.2124@TK2MSFTNGP15.phx.gbl...
> I have written a Winsock client/server application. When the client is
> finished it issues a closesocket(). If I run it again it gets an
FD_CONNECT
> from the server with NetworkEvents.lNetworkEvents = 0. However, the server
> never gets any events (I am expecting at least an FD_ACCEPT) .
>
> When a connecting client disconnects from a listening server is there
> something that the server should do in order to hear new connection
> attempts? I have issuing bind() again (error) and listen() again() (return
> code success) to no avail. The listening server never hears new connection
> attempts.
>
> Many thanks.
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Can't say for sure what are you doing, but it sounds like
you are mixing up the listening and accepted sockets.
You are supposed to be listening continuously on the
listening socket. When a connection arrives you should
accept it and continue listening right away. The accepted
socket carries out all communication with the client, the
listening socket carries no data.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
news:%23tqjhHj6EHA.2124@TK2MSFTNGP15.phx.gbl...
>I have written a Winsock client/server application. When the client is
> finished it issues a closesocket(). If I run it again it gets an
> FD_CONNECT
> from the server with NetworkEvents.lNetworkEvents = 0. However, the server
> never gets any events (I am expecting at least an FD_ACCEPT) .
>
> When a connecting client disconnects from a listening server is there
> something that the server should do in order to hear new connection
> attempts? I have issuing bind() again (error) and listen() again() (return
> code success) to no avail. The listening server never hears new connection
> attempts.
>
> Many thanks.
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

What do I have to do to "continue listening"? Make another call to listen()?
I thought that listening was the continuing state after the first call to
listen() until shutdown()?

Many thanks.

"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:uAD7Lts6EHA.4028@TK2MSFTNGP15.phx.gbl...
> Can't say for sure what are you doing, but it sounds like
> you are mixing up the listening and accepted sockets.
> You are supposed to be listening continuously on the
> listening socket. When a connection arrives you should
> accept it and continue listening right away. The accepted
> socket carries out all communication with the client, the
> listening socket carries no data.
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@mvps.org
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
> "Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
> news:%23tqjhHj6EHA.2124@TK2MSFTNGP15.phx.gbl...
> >I have written a Winsock client/server application. When the client is
> > finished it issues a closesocket(). If I run it again it gets an
> > FD_CONNECT
> > from the server with NetworkEvents.lNetworkEvents = 0. However, the
server
> > never gets any events (I am expecting at least an FD_ACCEPT) .
> >
> > When a connecting client disconnects from a listening server is there
> > something that the server should do in order to hear new connection
> > attempts? I have issuing bind() again (error) and listen() again()
(return
> > code success) to no avail. The listening server never hears new
connection
> > attempts.
> >
> > Many thanks.
> >
> >
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

It does sound like I'm doing that. However, I've checked my code and I'm
not. When the client closes its socket the server closes the accept()ed
socket. The behavior of the program is very odd.

- Andrew

"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:uAD7Lts6EHA.4028@TK2MSFTNGP15.phx.gbl...
> Can't say for sure what are you doing, but it sounds like
> you are mixing up the listening and accepted sockets.
> You are supposed to be listening continuously on the
> listening socket. When a connection arrives you should
> accept it and continue listening right away. The accepted
> socket carries out all communication with the client, the
> listening socket carries no data.
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@mvps.org
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
> "Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
> news:%23tqjhHj6EHA.2124@TK2MSFTNGP15.phx.gbl...
> >I have written a Winsock client/server application. When the client is
> > finished it issues a closesocket(). If I run it again it gets an
> > FD_CONNECT
> > from the server with NetworkEvents.lNetworkEvents = 0. However, the
server
> > never gets any events (I am expecting at least an FD_ACCEPT) .
> >
> > When a connecting client disconnects from a listening server is there
> > something that the server should do in order to hear new connection
> > attempts? I have issuing bind() again (error) and listen() again()
(return
> > code success) to no avail. The listening server never hears new
connection
> > attempts.
> >
> > Many thanks.
> >
> >
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Found it. WSAEnumNetworkEvents() was trapping the accepted socket, not the
listening socket. My design happened to initialize the two to the same value
before the first accept(), hence the initial successful connection.

Thanks for your help! You pointed me in the right direction.

Happy New Year.

- Andrew
"Alexander Nickolov" <agnickolov@mvps.org> wrote in message
news:uAD7Lts6EHA.4028@TK2MSFTNGP15.phx.gbl...
> Can't say for sure what are you doing, but it sounds like
> you are mixing up the listening and accepted sockets.
> You are supposed to be listening continuously on the
> listening socket. When a connection arrives you should
> accept it and continue listening right away. The accepted
> socket carries out all communication with the client, the
> listening socket carries no data.
>
> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD
> email: agnickolov@mvps.org
> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================
> "Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
> news:%23tqjhHj6EHA.2124@TK2MSFTNGP15.phx.gbl...
> >I have written a Winsock client/server application. When the client is
> > finished it issues a closesocket(). If I run it again it gets an
> > FD_CONNECT
> > from the server with NetworkEvents.lNetworkEvents = 0. However, the
server
> > never gets any events (I am expecting at least an FD_ACCEPT) .
> >
> > When a connecting client disconnects from a listening server is there
> > something that the server should do in order to hear new connection
> > attempts? I have issuing bind() again (error) and listen() again()
(return
> > code success) to no avail. The listening server never hears new
connection
> > attempts.
> >
> > Many thanks.
> >
> >
>
>
 
G

Guest

Guest
Archived from groups: microsoft.public.windowsnt.protocol.tcpip,microsoft.public.win32.programmer.networks (More info?)

Glad you found it. :)

Happy New Year to you too.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
news:upnHGD36EHA.1596@tk2msftngp13.phx.gbl...
> Found it. WSAEnumNetworkEvents() was trapping the accepted socket, not the
> listening socket. My design happened to initialize the two to the same
> value
> before the first accept(), hence the initial successful connection.
>
> Thanks for your help! You pointed me in the right direction.
>
> Happy New Year.
>
> - Andrew
> "Alexander Nickolov" <agnickolov@mvps.org> wrote in message
> news:uAD7Lts6EHA.4028@TK2MSFTNGP15.phx.gbl...
>> Can't say for sure what are you doing, but it sounds like
>> you are mixing up the listening and accepted sockets.
>> You are supposed to be listening continuously on the
>> listening socket. When a connection arrives you should
>> accept it and continue listening right away. The accepted
>> socket carries out all communication with the client, the
>> listening socket carries no data.
>>
>> --
>> =====================================
>> Alexander Nickolov
>> Microsoft MVP [VC], MCSD
>> email: agnickolov@mvps.org
>> MVP VC FAQ: http://www.mvps.org/vcfaq
>> =====================================
>> "Andrew Chalk" <achalk@XXXmagnacartasoftware.com> wrote in message
>> news:%23tqjhHj6EHA.2124@TK2MSFTNGP15.phx.gbl...
>> >I have written a Winsock client/server application. When the client is
>> > finished it issues a closesocket(). If I run it again it gets an
>> > FD_CONNECT
>> > from the server with NetworkEvents.lNetworkEvents = 0. However, the
> server
>> > never gets any events (I am expecting at least an FD_ACCEPT) .
>> >
>> > When a connecting client disconnects from a listening server is there
>> > something that the server should do in order to hear new connection
>> > attempts? I have issuing bind() again (error) and listen() again()
> (return
>> > code success) to no avail. The listening server never hears new
> connection
>> > attempts.
>> >
>> > Many thanks.
>> >
>> >
>>
>>
>
>