Re: How do you close a port immediately?
- From: Lew Pitcher <Lew.Pitcher@xxxxxx>
- Date: Mon, 19 Dec 2005 09:27:55 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Steffen wrote:
> Hi,
>
>> I'm playing around with sockets at the moment. Currently reading up
>> some online guides and experimenting on my own.
>>
>> After the server is launched, it will be there sitting like a duck
>> until it receives something. Usually if I need to make amendments to
>> the code, i will press ctrl+c to terminate it. After termination , the
>> port 9999 is still active and will be in TIME_WAIT status.
>>
>> Because during this TIME_WAIT period, I can still launch the simple
>> stream server. But netstat shows that port 9999 will still be in
>> TIME_WAIT period instead of LISTEN. The simple stream client will
>> encounter perror of "Connection Refused" during this TIME_WAIT period.
>
>
> you can install a handler for the SIGINT signal that is invoked by
> ctrl+c and shut down your sockets properly.
The OP should also use the SO_REUSEADDR socket() option (in the first
instance of the server) to permit the restarted (second instance) server to
claim the port that's in TIME_WAIT status.
- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFDpsKwagVFX4UWr64RAqPjAKDpZpQ1QWoBQBZ1LIpUb5lbEFb2DgCfSske
chfAKEfjst/ptYweFLraeyk=
=chPS
-----END PGP SIGNATURE-----
.
- Follow-Ups:
- Re: How do you close a port immediately?
- From: Steven
- Re: How do you close a port immediately?
- References:
- How do you close a port immediately?
- From: Steven
- Re: How do you close a port immediately?
- From: Steffen
- How do you close a port immediately?
- Prev by Date: Re: How do you close a port immediately?
- Next by Date: Re: recv() - How do you know the length of buffer that you are going to receive?
- Previous by thread: Re: How do you close a port immediately?
- Next by thread: Re: How do you close a port immediately?
- Index(es):
Relevant Pages
|