1*61181Sbostic.\" Copyright (c) 1983, 1993 2*61181Sbostic.\" The Regents of the University of California. All rights reserved. 320207Smckusick.\" 443568Strent.\" %sccs.include.redist.man% 520207Smckusick.\" 6*61181Sbostic.\" @(#)bind.2 8.1 (Berkeley) 06/04/93 736759Sbostic.\" 847208Scael.Dd 947208Scael.Dt BIND 2 1047208Scael.Os BSD 4.2 1147208Scael.Sh NAME 1247208Scael.Nm bind 1347208Scael.Nd bind a name to a socket 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <sys/types.h> 1647208Scael.Fd #include <sys/socket.h> 1747208Scael.Ft int 1847208Scael.Fn bind "int s" "struct sockaddr *name" "int namelen" 1947208Scael.Sh DESCRIPTION 2047208Scael.Fn Bind 2120207Smckusickassigns a name to an unnamed socket. 2220207SmckusickWhen a socket is created 2320207Smckusickwith 2447208Scael.Xr socket 2 2520207Smckusickit exists in a name space (address family) 2620207Smckusickbut has no name assigned. 2747208Scael.Fn Bind 2828359Sannerequests that 2947208Scael.Fa name 3020207Smckusickbe assigned to the socket. 3147208Scael.Sh NOTES 3220207SmckusickBinding a name in the UNIX domain creates a socket in the file 3323792Ssechrestsystem that must be deleted by the caller when it is no longer 3420207Smckusickneeded (using 3547208Scael.Xr unlink 2 ) . 3647208Scael.Pp 3720207SmckusickThe rules used in name binding vary between communication domains. 3820207SmckusickConsult the manual entries in section 4 for detailed information. 3947208Scael.Sh RETURN VALUES 4020207SmckusickIf the bind is successful, a 0 value is returned. 4147208ScaelA return value of -1 indicates an error, which is 4247208Scaelfurther specified in the global 4347208Scael.Va errno . 4447208Scael.Sh ERRORS 4547208ScaelThe 4647208Scael.Fn bind 4747208Scaelcall will fail if: 4847208Scael.Bl -tag -width EADDRNOTAVA 4947208Scael.It Bq Er EBADF 5047208Scael.Fa S 5147208Scaelis not a valid descriptor. 5247208Scael.It Bq Er ENOTSOCK 5347208Scael.Fa S 5447208Scaelis not a socket. 5547208Scael.It Bq Er EADDRNOTAVAIL 5620207SmckusickThe specified address is not available from the local machine. 5747208Scael.It Bq Er EADDRINUSE 5820207SmckusickThe specified address is already in use. 5947208Scael.It Bq Er EINVAL 6020207SmckusickThe socket is already bound to an address. 6147208Scael.It Bq Er EACCES 6220207SmckusickThe requested address is protected, and the current user 6320207Smckusickhas inadequate permission to access it. 6447208Scael.It Bq Er EFAULT 6547208ScaelThe 6647208Scael.Fa name 6747208Scaelparameter is not in a valid part of the user 6820207Smckusickaddress space. 6947208Scael.El 7047208Scael.Pp 7121004SmckusickThe following errors are specific to binding names in the UNIX domain. 7247208Scael.Bl -tag -width EADDRNOTAVA 7347208Scael.It Bq Er ENOTDIR 7421004SmckusickA component of the path prefix is not a directory. 7547208Scael.It Bq Er EINVAL 7621004SmckusickThe pathname contains a character with the high-order bit set. 7747208Scael.It Bq Er ENAMETOOLONG 7821004SmckusickA component of a pathname exceeded 255 characters, 7921004Smckusickor an entire path name exceeded 1023 characters. 8047208Scael.It Bq Er ENOENT 8121004SmckusickA prefix component of the path name does not exist. 8247208Scael.It Bq Er ELOOP 8321004SmckusickToo many symbolic links were encountered in translating the pathname. 8447208Scael.It Bq Er EIO 8521004SmckusickAn I/O error occurred while making the directory entry or allocating the inode. 8647208Scael.It Bq Er EROFS 8721004SmckusickThe name would reside on a read-only file system. 8847208Scael.It Bq Er EISDIR 8947208ScaelAn empty pathname was specified. 9047208Scael.El 9147208Scael.Sh SEE ALSO 9247208Scael.Xr connect 2 , 9347208Scael.Xr listen 2 , 9447208Scael.Xr socket 2 , 9547208Scael.Xr getsockname 2 9647208Scael.Sh HISTORY 9747208ScaelThe 9847208Scael.Nm 9947208Scaelfunction call appeared in 10047208Scael.Bx 4.2 . 101