Subject: Re: RPC over UDP: connect the socket?
To: None <M.Drochner@fz-juelich.de>
From: Matthias Drochner <drochner@zel459.zel.kfa-juelich.de>
List: tech-net
Date: 04/12/1999 19:54:57
drochner@zel459.zel.kfa-juelich.de said:
> "connect()"ing the UDP socket before send/recv helps a lot, one gets
> errors from the network layer immediately. 

[followup to my own posting]

I've tried it and found that it isn't the right thing - it
fails if a server replies with another IP address.

But there is another way to solve the original problem: use
TCP to register RPC services with the portmapper. Remote clients
wouldn't benefit, but it's still an improvement for servers.

The appended patch works well for me - are there reasons
not to change it? (the RPC_ANYSOCK is cosmetics of course)

best regards
Matthias


Index: pmap_clnt.c
===================================================================
RCS file: /cvsroot/src/lib/libc/rpc/pmap_clnt.c,v
retrieving revision 1.12
diff -c -2 -r1.12 pmap_clnt.c
*** pmap_clnt.c	1999/03/25 01:16:11	1.12
--- pmap_clnt.c	1999/04/12 17:50:58
***************
*** 60,64 ****
  #endif
  
- static const struct timeval timeout = { 5, 0 };
  static const struct timeval tottimeout = { 60, 0 };
  
--- 60,63 ----
***************
*** 75,79 ****
  {
  	struct sockaddr_in myaddress;
! 	int socket = -1;
  	CLIENT *client;
  	struct pmap parms;
--- 74,78 ----
  {
  	struct sockaddr_in myaddress;
! 	int socket = RPC_ANYSOCK;
  	CLIENT *client;
  	struct pmap parms;
***************
*** 82,87 ****
  	if (get_myaddress(&myaddress) != 0)
  		return (FALSE);
! 	client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
! 	    timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
  	if (client == (CLIENT *)NULL)
  		return (FALSE);
--- 81,86 ----
  	if (get_myaddress(&myaddress) != 0)
  		return (FALSE);
! 	client = clnttcp_create(&myaddress, PMAPPROG, PMAPVERS,
! 	    &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
  	if (client == (CLIENT *)NULL)
  		return (FALSE);
***************
*** 109,113 ****
  {
  	struct sockaddr_in myaddress;
! 	int socket = -1;
  	CLIENT *client;
  	struct pmap parms;
--- 108,112 ----
  {
  	struct sockaddr_in myaddress;
! 	int socket = RPC_ANYSOCK;
  	CLIENT *client;
  	struct pmap parms;
***************
*** 116,121 ****
  	if (get_myaddress(&myaddress) != 0)
  		return (FALSE);
! 	client = clntudp_bufcreate(&myaddress, PMAPPROG, PMAPVERS,
! 	    timeout, &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
  	if (client == (CLIENT *)NULL)
  		return (FALSE);
--- 115,120 ----
  	if (get_myaddress(&myaddress) != 0)
  		return (FALSE);
! 	client = clnttcp_create(&myaddress, PMAPPROG, PMAPVERS,
! 	    &socket, RPCSMALLMSGSIZE, RPCSMALLMSGSIZE);
  	if (client == (CLIENT *)NULL)
  		return (FALSE);