Web lists-archives.com

Re: RPC clnt_create() adress already in use

PAULUS, Raimund, TI-ABN wrote:
In our environment we have a Linux-Server and several Windows-PCs (Windows XP SP3, in the past Windows NT too). On the Linux-Server RPC-Services (Remote Procedure Call) are running, one service for one Windows-PC each. To build the RPC-clients on the Windows-boxes, I used Cygwin 1.5.18 and actually Cygwin 2.5.1 (because we now have Windows 7 too).

The RPC-Client (*.exe) on the Windows-box is started at any time by hand, establishes a connection to the server (clnt_create), executes a few calls to the server (clnt_call), closes the connection (clnt_destroy) and exits. The time-interval between the program starts can be 10 seconds up to 2 minutes.

This worked over many years without any error (Cygwin 1.5.18).
Now I upgraded to Cygwin 2_5_1 (libtirpc instead librpc) and there are problems. Sometimes the RPC-Client cannot establish a connection to the server. The error message from clnt_spcreateerror():

Remote system error - Address already in use

I think it is "EADDRINUSE".

I can only answer generally as I haven't tried your testcase and don't know anything about either RPC library on Cygwin. If EADDRINUSE is the error you're getting, it might be due to a difference between libtirpc and the older librpc. When a program binds a specific address and port to a socket, uses the socket then later closes it, the system keeps the <address, port> tuple in a "locked" state until enough time has passed for the other end of the connection to notice the connection's been closed. During that time, attempting to bind() with the same address and port will result in EADDRINUSE. It's a TCP/IP safety mechanism.

If you wish to override that behavior, you set a specific option SO_REUSEADDR on the socket with setsockopt() before you issue the bind(). Perhaps libtirpc is not doing that, though librpc was doing that. Only way to know is to examine the source to both libraries. It's possible an strace of a broken session compared to an strace of a working session might shed some light.


Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple