public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: "PAULUS, Raimund, TI-ABN" <Raimund.Paulus@dillinger.biz>
To: "'cygwin@cygwin.com'" <cygwin@cygwin.com>
Subject: RPC clnt_create() adress already in use
Date: Fri, 22 Sep 2017 07:22:00 -0000	[thread overview]
Message-ID: <59D90AF8D70E9740907BACDE2BCB5208365F7F6C@RESW102.resdom01.local> (raw)

[-- Attachment #1: Type: text/plain, Size: 4916 bytes --]

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 wrote a program for tests in Cygwin 1.5.18, 1.7.32 and 2.5.1:

The program reads argv[1] as a sleeptime. If no argv[1] exists, sleeptime has a default value of  10 seconds. Afterwards is a loop (20 times) of the following actions:

-       establish a connection to the server and sleep for 1 second

-       destroy the connection

-       sleep(sleeptime)

test_rpc.c:


/*=================*/
/*  Include-Files  */
/*=================*/
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
/*#include <posix.h>*/
#include <sys/types.h>
#include <sys/stat.h>

#include <rpc/rpc.h>

/*===========================================*/
/*  global definitions                                                              */
/*===========================================*/

char local_errmsg[512];

char host[] = "nazv";
u_int prognum = 0x2000002F;
u_int versnum = 2;
char nettype[] = "tcp";

/*=============================*/
/*  main-program                                     */
/*=============================*/
int main (int argc, char *argv[])
{
int retval = 0;
int sleeptime = 0;
CLIENT *cl;     /* a client handle */

  // read sleep-Time
  if(argc < 2)
  {
    printf("no input for sleep-Time --> default\n");
    sleeptime = 10;
  }
  else
  {
    char *endptr;
    errno = 0;
    sleeptime = (int)strtol(argv[1], &endptr, 10);
    if ( (errno == ERANGE && (sleeptime == LONG_MAX || sleeptime == LONG_MIN))
         || (errno != 0 && sleeptime == 0))
    {
      fprintf(stderr, "input for sleeptime (%s) invalid: %s\n",
                      argv[1], strerror(errno));
      exit(1);
    }
  }

  printf("sleep-Time = %d \n", sleeptime);

  // loop for 20 connection
  for(int i=0; i<20; i++)
  {
    if(!(cl = clnt_create(host, prognum, versnum, nettype)))
    {
      // couldn't start client handle
      sprintf(local_errmsg, "%s: %s", host, clnt_spcreateerror("clnt_create"));
      retval = -1;
      break;
    }

    printf("connection nr. %d established \n", i+1);
    sleep(1);

    clnt_destroy(cl);
    printf("connection closed\n");

    printf("wait for %d sec.\n", sleeptime);
    sleep(sleeptime);

  };

  if(retval < 0)
    fprintf(stderr, "%s\n", local_errmsg);

  return(0);
} // end main()


Test 1: The program is started with argument "60" (sleep = 60 secs.)

Results:

Cygwin 1_5_18 (Windows XP, Windows 7)
The loop is completed without error (20 times the connection was opened and closed).

Cygwin 1_7_32 and 2_5_1 (Windows 7)
After the first connection is closed, a second connection in the loop is not possible (error message above) and the program exits.

RPC-Client on Linux (openSuSe Leap 42.1)
The loop is completed without error (20 times the connection was opened and closed).



Test 2: The program is started with argument "0" (sleep = 0 secs.)

Results:

Cygwin 1_5_18 (Windows XP, Windows 7)
The loop is completed without error (20 times the connection was opened and closed).

Cygwin 1_7_32 and 2_5_1 (Windows 7)
After the first connection is closed, a second connection in the loop is not possible (error message above) and the program exits.

RPC-Client on Linux (openSuSe Leap 42.1)
The loop is completed without error (20 times the connection was opened and closed).



Test 3: The program is started with argument "0" (sleep = 0 secs.)
Windows 7 only
Cygwin 1_7_32 and 2_5_1
After the program exited with the error, the program was immediately restarted. The start was ok (but always the program exited with the known error). But after several starts a new error was there:

Remote system error - Connection timed out


What is the reason for the error? I have to develop RPC-Clients for Windows XP SP3 and Windows 7.


Raimund Paulus


             reply	other threads:[~2017-09-22  7:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-22  7:22 PAULUS, Raimund, TI-ABN [this message]
2017-09-24  9:49 ` Mark Geisert
2017-09-25  6:44 PAULUS, Raimund, TI-ABN
2017-09-27  9:50 ` Mark Geisert
2017-09-27 12:51 PAULUS, Raimund, TI-ABN
2017-09-29  9:52 PAULUS, Raimund, TI-ABN
2017-09-29 17:36 ` Mark Geisert
2017-12-19 16:13 PAULUS, Raimund, TI-ABN
2017-12-28  0:03 ` Mark Geisert
2018-01-30  7:01 PAULUS, Raimund, TI-ABN
2018-01-30  9:05 ` Mark Geisert
2018-01-30 10:07 PAULUS, Raimund, TI-ABN
2018-01-31  8:15 ` Mark Geisert
2018-01-31  9:11   ` Corinna Vinschen
2018-01-31  9:35     ` Mark Geisert
2018-02-02  8:11       ` Mark Geisert
2018-02-02 12:58 PAULUS, Raimund, TI-ABN
2018-02-05  8:19 PAULUS, Raimund, TI-ABN
2018-02-05 10:29 ` Mark Geisert
2018-02-05 11:26   ` Corinna Vinschen
2018-02-05 13:34     ` Corinna Vinschen
2018-02-05 14:06       ` Corinna Vinschen
2018-02-05 20:15         ` Corinna Vinschen
2018-02-05 14:58 PAULUS, Raimund, TI-ABN
2018-02-06 11:29 PAULUS, Raimund, TI-ABN
2018-02-06 14:20 ` Corinna Vinschen
2018-02-07  6:54   ` Mark Geisert
2018-02-27  9:54 PAULUS, Raimund, TI-ABN
2018-02-27 10:37 ` Corinna Vinschen
2018-02-28  6:00   ` Mark Geisert
2018-03-02 10:39 PAULUS, Raimund, TI-ABN
2018-03-08 11:44 PAULUS, Raimund, TI-ABN
2018-03-08 15:24 ` Corinna Vinschen
2018-03-08 23:00 ` Mark Geisert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59D90AF8D70E9740907BACDE2BCB5208365F7F6C@RESW102.resdom01.local \
    --to=raimund.paulus@dillinger.biz \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).