1 .\" @(#)bindresvport.3n 2.2 88/08/02 4.0 RPCSRC; from 1.7 88/03/14 SMI
2 .\" $NetBSD: bindresvport.3,v 1.13 2007/01/27 07:58:47 cbiere Exp $
10 .Nd bind a socket to a reserved privileged IP port
17 .Fn bindresvport "int sd" "struct sockaddr_in *sin"
19 .Fn bindresvport_sa "int sd" "struct sockaddr *sa"
24 are used to bind a socket descriptor to a reserved privileged
27 port number in the range 0-1023.
28 The routine returns 0 if it is successful,
29 otherwise -1 is returned and
31 set to reflect the cause of the error.
36 .Ft "struct sockaddr_in"
37 then the appropriate fields in the structure should be defined.
39 .Fa sin-\*[Gt]sin_family
40 must be initialized to the address family of the socket, passed by
43 .Fa sin-\*[Gt]sin_port
46 then a port (in the range 600-1023) will be
50 .Fa sin-\*[Gt]sin_port
51 will be updated to contain the allocated port.
58 a port will be allocated (as above).
59 However, there is no way for
61 to return the allocated port in this case.
63 can be used to determine the assigned port.
65 Only root can bind to a privileged port; this call will fail for any
74 acts exactly the same, with more neutral function prototype.
75 Note that both functions behave exactly the same, and
82 If the bind is successful, a 0 value is returned.
83 A return value of -1 indicates an error, which is
84 further specified in the global
88 .It Bq Er EPFNOSUPPORT
89 If second argument was supplied,
90 and address family did not match between arguments.
96 for any of the errors specified for the calls