Name

udp-socket-connect — connect a socket to a UDP server and chain

Synopsis

udp-socket-connect [--verbose] [--local-name name] [--local-address address] [--local-port port] [--numeric-host] [--numeric-service] [--check-interfaces] [--no-kill-IP-options] {host} {service} {next-prog}

Description

udp-socket-connect is a chain-loading utility that opens a UDP socket, connects it to host and service with connect(1), sets the socket to file descriptors 6 and 7 (closing whatever those descriptors were), and then chain loads to next-prog with the execvp(3) function. It sets up various conventional UCSPI environment variables that describe the local and remote ends of the connection. By UCSPI convention the chained-to program is expected to use file descriptor 6 for reading from the server and file descriptor 7 for writing to the server.

next-prog may contain its own command line options, which udp-socket-connect will ignore.

If the --numeric-host command line option is used, then no name lookup is done on host and it must be (a human readable form of) an IP address. If the --numeric-service command line option is used, then no name lookup is done on service and it must be a port number. Otherwise, host is looked up using the system name resolution facility and port can be an alphanumeric service name.

The --check-interfaces option prevents the use of any IPv4 addresses if there are no IPv4 addresses on any network interface, and the use of any IPv6 addresses if there are no IPv6 addresses. This isn't particularly useful on a dynamically configured system where network interface IP addresses can come and go.

Following the UCSPI conventions, udp-socket-connect sets up several environment variables containing information about the UDP connection.

PROTO

This always has the value UDP.

UDPLOCALIP

The local (client) IP address of the connecting socket, in human-readable form. Normally, the operating system assigns this; but an explicit assignment can be requested with the --local-address command-line option, where address is a numeric IP address that is available and matches the protocol of the remote end.

UDPLOCALPORT

The local (client) port number of the connecting socket. Normally, the operating system assigns this; but an explicit assignment can be requested with the --local-port command-line option, where port is a numeric port number.

UDPLOCALHOST

The value of name set by the --local-name option; guaranteed unset if that option is not used.

UDPREMOTEIP

The remote (server) IP address of the connected socket, in human-readable form.

UDPREMOTEPORT

The remote (server) port number of the connected socket.

UDPREMOTEINFO

Guaranteed unset.

UDPREMOTEHOST

Guaranteed unset.

If the --verbose option is used, udp-socket-connect logs information about connections made.

The --no-kill-IP-options command line option sets options on the connected socket. It permits IP options (which are removed by default) so that clients can set source routes.

Author

Jonathan de Boyne Pollard