From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20860 invoked by alias); 27 Sep 2017 09:50:07 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 20824 invoked by uid 89); 27 Sep 2017 09:50:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.7 required=5.0 tests=AWL,BAYES_50,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=adress, hallo, delivers, H*c:ISO-8859-1 X-HELO: m0.truegem.net Received: from m0.truegem.net (HELO m0.truegem.net) (69.55.228.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Sep 2017 09:50:03 +0000 Received: (from daemon@localhost) by m0.truegem.net (8.12.11/8.12.11) id v8R9o2Pl017890 for ; Wed, 27 Sep 2017 02:50:02 -0700 (PDT) (envelope-from mark@maxrnd.com) Received: from 76-217-5-154.lightspeed.irvnca.sbcglobal.net(76.217.5.154), claiming to be "[192.168.1.100]" via SMTP by m0.truegem.net, id smtpdE4HZ2R; Wed Sep 27 02:49:57 2017 Subject: Re: RPC clnt_create() adress already in use To: cygwin@cygwin.com References: <59D90AF8D70E9740907BACDE2BCB52083660696D@RESW103.resdom01.local> From: Mark Geisert Message-ID: Date: Wed, 27 Sep 2017 09:50:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:49.0) Gecko/20100101 Firefox/49.0 SeaMonkey/2.46 MIME-Version: 1.0 In-Reply-To: <59D90AF8D70E9740907BACDE2BCB52083660696D@RESW103.resdom01.local> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2017-09/txt/msg00274.txt.bz2 Hello Raimund, Let's keep this on the mailing list please. PAULUS, Raimund, TI-ABN wrote: > Hallo Mark Geisert, > > many thanks for your answer. I supposed this too. > > I included in my source code the following function calls after clnt_create(): > > int fd = 0; > bool bool_ret = clnt_control(cl, CLGET_FD, &fd); if(bool_ret == true) { > printf("fd: %d\n", fd); > > int enable = 1; > retval = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)); > if(retval < 0) > fprintf(stderr, "Fehler setsockopt(): %s\n", strerror(errno)); } > > The function clnt_control() delivers the socket of the RPC-Client-Handle. > The result is the same as before. Moreover i think, the effect of setsockopt() would be valid only during the process is running (my test scenarios 1 and 2). > But it wouldn't change anything regarding my test scenario 3 (several restarts). > > Raimund I looked through the libtirpc source code and nowhere is SO_REUSEADDR being set. You are on the right track with how to do it, but by the time clnt_create() returns to you it is already too late. As far as I can tell there is no way to get access to the socket between the time it's created within libtirpc and the time it's made available to you by clnt_create(). I did try running your testcase (thanks for supplying that) but I don't have a local machine running RPC services and don't wish to poke at random machines on the Internet ;-). I had to compile it as so: gcc -g -o test_rpc -I/usr/include/tirpc test_rpc.c -ltirpc You are taking care to compile against the correct RPC-package includes and link against the correct RPC-package libraries, yes? Speculation: There might be a way to decompose what clnt_create() does into other libtirpc functions that accomplish the same thing, but in smaller pieces such that you could set the socket option before bind() is called. That would be a fair amount of work though and given my cursory look at the source I don't know if it's even possible. ..mark -- 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