× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Just a follow-up in case anyone else searches for this in the future. In
order to achieve the goal of letting the listener program run in a
continuous loop without having to wait for the wait time to expire, I
found that it is necessary to set the SO_REUSEADDR for both the listen
socket and the socket returned by accept(). Otherwise, the second and
subsequent runs always end up with "Address already in use" on the bind
(until the timer expires).

I ended up with the following program flow:

PGM
CLPtop:
misc. processing
socketpgm {
listen_sock = socket
setsockopt listen_sock SO_REUSEADDR
bind
listen
sock2 = accept
close listen_sock
setsockopt sock2 SO_REUSEADDR
fcntl(sock2, F_SETFL, O_NONBLOCK)
perform conversation on sock2
close sock2
}
misc. processing
goto cmdlabel(CLPtop)
ENDPGM

Thanks again, Scott K, for pointing me in the right direction.

-Marty

-----Original Message-----
From: Urbanek, Marty
Sent: Monday, July 23, 2007 6:54 PM
To: 'midrange-l@xxxxxxxxxxxx'
Subject: RE: Re: TCP/IP sockets problem: SO_REUSEADDR

Scott,

Thanks a million. I just tested it out. That's what was wrong. I needed
to setsockopt() on the socket that was returned by accept() rather than
the original one from socket(). Now it all makes sense.

THANKS AGAIN! It really helps to have somebody to kick the tires with.

-Marty


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.