Socket Question, How to 'quickly' free port number.

Socket Question, How to 'quickly' free port number.

Post by Bill Luehrman » Wed, 27 Nov 1996 04:00:00



My situation is this, we have two tasks that communicate
via a socket. At startup, both tasks are given an port
number so they know how to talk to each other. For some
reason, when both tasks are shutdown and restarted, an
error code is returned indicating that the port is busy.
If we wait awhile (2 minutes), AIX frees up the port.

Does anybody know how to force AIX to quickly free the port?

Please email your reply

 
 
 

Socket Question, How to 'quickly' free port number.

Post by Andrew Gier » Thu, 28 Nov 1996 04:00:00


 Bill> My situation is this, we have two tasks that communicate
 Bill> via a socket. At startup, both tasks are given an port
 Bill> number so they know how to talk to each other. For some
 Bill> reason, when both tasks are shutdown and restarted, an
 Bill> error code is returned indicating that the port is busy.
 Bill> If we wait awhile (2 minutes), AIX frees up the port.

 Bill> Does anybody know how to force AIX to quickly free the port?

Wrong question. The right question is "how do I use the port again
without waiting", and the short answer is: set the SO_REUSEADDR option.

See the unix-socket-faq, regularly posted to comp.unix.programmer
and comp.answers, and also available at:

  http://www.auroraonline.com/sock-faq
  http://kipper.york.ac.uk/~vic/sock-faq
  ftp://rtfm.mit.edu/pub/usenet/news.answers/unix-faq/socket

--

"Ceterum censeo Microsoftam delendam esse" - Alain Knaff in nanam

 
 
 

Socket Question, How to 'quickly' free port number.

Post by Andrew Pecheno » Thu, 28 Nov 1996 04:00:00


Quote:> My situation is this, we have two tasks that communicate
> via a socket. At startup, both tasks are given an port
> number so they know how to talk to each other. For some
> reason, when both tasks are shutdown and restarted, an
> error code is returned indicating that the port is busy.
> If we wait awhile (2 minutes), AIX frees up the port.

Hello!

while opening socket at first time use

int one=1;
setsockopt(socket,SOL_SOCKET,SO_REUSEADDR,&one,sizeof(one));

With best regards,

andy

---

PGP keyid:F3C47B41
fingerprint:A6 DF D1 30 09 2C 9B DE  A0 50 DF 52 DD 7A FF 08

 
 
 

1. How can I find a free 'port' in socket programming?

Hi, all,

I am new to socket programming. When I am writing a socket
server, how can I know which port is free and can be used
by this server? Is there any system call or function on it?

Best regards,
P.W.D.

Sent via Deja.com http://www.deja.com/
Before you buy.

2. IDE removable internal drives

3. Free as in 'Freedom' not 'Free Beer'

4. SRM crash on PWS 600 & RH5.2

5. Finding a socket's local port number

6. Redhat 5.1 with Apache httpd: Is this right?

7. Flexfax -- "Can not find port number for 'fax' service" -- ???

8. IP Address Change

9. 'talk' and socket/port usage - anything not documented?

10. Numbering a text file (UNIX 'number' command)

11. Quickly freeing up socket after process exit on Solaris