12.07.2015 Views

z/VM: TCP/IP Programmer's Reference - z/VM - IBM

z/VM: TCP/IP Programmer's Reference - z/VM - IBM

z/VM: TCP/IP Programmer's Reference - z/VM - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

ind()EAFNOSUPPORTEADDRINUSEEINVALto copy the address into a non-writable portion ofthe caller’s virtual storage.Indicates that the address family is not supported(it is not AF_IUCV or AF_INET).Indicates that the address is already in use. See theSO_REUSEADDR option described under“getsockopt()” on page 45 and theSO_REUSEADDR described under the“setsockopt()” on page 76.Indicates that the socket is already bound to anaddress. For example, trying to bind a name to asocket that is in the connected state. If you areusing sockets in the AF_IUCV domain, this erroralso occurs if NULL characters appear in thesiucv_nodeid or siucv_user_id fields. This value isalso returned if namelen is not the expected length.Examples: The following are examples of the bind() call. The internet address andport must be in network byte order. To put the port into network byte order, autility routine, htons(), is called to convert a short integer from host byte order tonetwork byte order. The address field is set using another utility routine,inet_addr(), which takes a character string representing the dotted-decimal addressof an interface and returns the binary internet address representation in networkbyte order. Finally, you should zero the structure before using it to ensure that thename requested does not set any reserved fields. For examples of how a clientmight connect to servers, see “connect()” on page 27.AF_INET Domain Example: The following example illustrates the bind() callbinding to interfaces in the AF_INET domain.int rc;int s;struct sockaddr_in myname;struct sockaddr_iucv myvmname;int bind(int s, struct sockaddr *name, int namelen);/* Bind to a specific interface in the internet domain *//* make sure the sin_zero field is cleared */memset(&myname, 0, sizeof(myname));myname.sin_family = AF_INET;myname.sin_addr.s_addr = inet_addr(“129.5.24.1”); /* specific interface */myname.sin_port = htons(1024);.rc = bind(s, (struct sockaddr *) &myname, sizeof(myname));/* Bind to all network interfaces in the internet domain *//* make sure the sin_zero field is cleared */memset(&myname, 0, sizeof(myname));myname.sin_family = AF_INET;myname.sin_addr.s_addr = INADDR_ANY; /* specific interface */myname.sin_port = htons(1024);.rc = bind(s, (struct sockaddr *) &myname, sizeof(myname));/* Bind to a specific interface in the internet domain.Let the system choose a port *//* make sure the sin_zero field is cleared */memset(&myname, 0, sizeof(myname));myname.sin_family = AF_INET;myname.sin_addr.s_addr = inet_addr(“129.5.24.1”); /* specific interface */myname.sin_port.= 0;26 z/<strong>VM</strong>: <strong>TCP</strong>/<strong>IP</strong> Programmer’s <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!