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.

Chapter 2. C Sockets Application Program InterfaceProgramming with C SocketsThis chapter describes the C socket application program interface (API) providedwith <strong>TCP</strong>/<strong>IP</strong>. Use the socket routines in your C program to interface with the <strong>TCP</strong>,UDP, and <strong>IP</strong> protocols. This allows you to communicate across networks withother programs. You can, for example, make use of socket routines when you writea client program that must communicate with a server program running onanother computer.To use the C socket API, you should know C language programming.For more information about C sockets, see the <strong>IBM</strong> AIX ® Operating System Technical<strong>Reference</strong>: System Calls and Subroutines.The <strong>VM</strong> C socket API provides a standard interface to the transport andinternetwork layer interfaces of <strong>TCP</strong>/<strong>IP</strong>. It supports three socket types: stream,datagram, and raw. Stream and datagram sockets interface to the transport layerprotocols, and raw sockets interface to the network layer protocols. Theprogrammer chooses the most appropriate interface for an application.Socket Programming ConceptsBefore programming with the C socket API, you should consider the followingimportant concepts.What is a Socket?A socket is an endpoint for communication that can be named and addressed in anetwork. From an application program perspective, it is a resource allocated by thevirtual machine. It is represented by an integer called a socket descriptor.The socket interface was designed to provide applications with a network interfacethat hides the details of the physical network. The interface is differentiated by thedifferent services that are provided. Stream, datagram, and raw sockets each definea different service available to applications.The stream socket interface defines a reliable connection-oriented service. Data issent without errors or duplication and is received in the same order as it is sent.Flow control is built in to avoid data overruns. No boundaries are imposed on thedata; it is considered to be a stream of bytes. An example of an application thatuses stream sockets is Telnet.The datagram socket interface defines a connectionless service. Datagrams are sentas independent packets. The service provides no guarantees; data can be lost orduplicated, and datagrams can arrive out of order. The size of a datagram islimited to the size that can be sent in a single transaction (currently the default is8192 and the maximum is 32,767). No disassembly and reassembly of packets isperformed. An example of an application that uses datagram sockets is theNetwork File System (NFS).© Copyright <strong>IBM</strong> Corp. 1987, 2001 5

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

Saved successfully!

Ooh no, something went wrong!