udpsocket - create an UDP socket and run a program


udpsocket: [options] host port command [arguments]


udpsocket creates a UDP socket, binds it to host and port and runs program with the remaining arguments.

options is a is a series of getopt or getopt_long style options. See below for more information.

The socket is described by host and port. host may be 0, allowing connections to any local IP address; or a dotted-decimal IP address, allowing connections only to that address; or a host name, allowing connections to the first IP address for that host. Host names are fed through qualification using dns_ip4_qualify.

port may be a name from /etc/services or a number; if it is 0, udpsocket will choose a free UDP port.


Child program options:

-C, --chroot=DIR
Change the working directory to DIR. Then change the root directory of the process to . (the current directory). This will be done after the socket has been created and before changing the group or user ID.

-F, --fd=N
Move socket handle to file descriptor N.

`N' may be a whitespace or comma separated list. The default is to move it to 5. Note that moving the socket to file descriptor 2 may disturb the output of error messages.

-g, --gid=GID
Group ID to change to.

udpsocket will switch to that group id after the socket has been set up. GID has to be a positive integer.

-u, --uid=UID
User ID to change to.

udpsocket will switch to that user id after the socket has been set up. UID has to be a positive integer.

-U, --uidgid
The same as -u $UID -g $GID.

Usually used together with envuidgid.

Data-gathering options:

-l, --localhost=NAME
Use NAME as local host name.

Do not look up the local host name in the DNS. This information is used to set the environment variable UDPLOCALHOST.

Verbosity options:

Print the local port number.

After preparing to receive connections, print the local port number to standard output.

-q, --quiet
Quiet. Do not print error messages.

Print error messages.

This is the default.

-v, --verbose
Verbose. Print error and status messages.

Show version information.

Show a list of options or the long help on one.

The use with an argument shows the long helptext of that option, without an argument it will list all options.

Show longer help texts for all or one variable

The use with an argument shows the long help for this option, without arguments it shows the long description of all options.


udpsocket sets the environment variables PROTO (to UDP), UDPLOCALPORT and UDPLOCALIP, and will set UDPLOCALHOST if this information is available. If udpsocket bound the socket to any local IP address then UDPLOCALIP will be ``'' and UDPLOCALHOST will be unset.


        # start a remote log receiving demon
        udpsocket 0 514 setuidgid remotelog unsyslogd
        # prepare for amanda
        udpsocket 0 10080 setuidgid amanda \
        udpwaitserver /whereever/amanda




Uwe Ohse


Uwe Ohse homepage

IODP tools