25.02.2013 Views

TCP/IP Tutorial and Technical Overview - IBM Redbooks

TCP/IP Tutorial and Technical Overview - IBM Redbooks

TCP/IP Tutorial and Technical Overview - IBM Redbooks

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

11.2 Application programming interfaces (APIs)<br />

11.2.1 The socket API<br />

An application programming interface (API) enables developers to write<br />

applications that can make use of <strong>TCP</strong>/<strong>IP</strong> services. The following sections<br />

provide an overview of the most common APIs for <strong>TCP</strong>/<strong>IP</strong> applications.<br />

The socket interface is one of several APIs to the communication protocols.<br />

Designed to be a generic communication programming interface, it was first<br />

introduced by the 4.2BSD UNIX-based system. Although the socket API for <strong>IP</strong>v4<br />

was never st<strong>and</strong>ardized, it has become a de facto industry st<strong>and</strong>ard, <strong>and</strong> RFC<br />

3493 was created to update the API for <strong>IP</strong>v6. More advanced <strong>IP</strong>v6 socket<br />

programming can be found in RFC 3542.<br />

The socket interface is differentiated by the following services provided to<br />

applications:<br />

► Stream sockets services<br />

Stream sockets provide a reliable connection-oriented service such as <strong>TCP</strong>.<br />

Data is sent without errors or duplication, <strong>and</strong> is received in the same order as<br />

it is sent. Flow control is built in to avoid data overruns. No boundaries are<br />

imposed on the exchanged data, which is considered a stream of bytes. An<br />

example of an application that uses stream sockets is the File Transfer<br />

Protocol (FTP).<br />

► Datagram sockets services<br />

Datagram sockets define a connectionless service such as UDP. Datagrams<br />

are sent as independent packets. The service does not guarantee successful<br />

delivery of the packets; data can be lost or duplicated, <strong>and</strong> datagrams can<br />

arrive out of order. No disassembly <strong>and</strong> reassembly of packets is performed.<br />

An example of an application that uses datagram sockets is the Network File<br />

System (NFS).<br />

► Raw sockets services<br />

Raw sockets allow direct access to lower layer protocols, such as <strong>IP</strong> <strong>and</strong><br />

ICMP. This interface is often used for testing new protocol implementations.<br />

An example of an application that uses raw sockets is the ping comm<strong>and</strong>.<br />

Additional information about sockets is in 4.1.2, “Sockets” on page 145. Socket<br />

APIs provide functions that enable applications to perform the following actions:<br />

► Initialize a socket<br />

► Bind (register) a socket to a port address<br />

410 <strong>TCP</strong>/<strong>IP</strong> <strong>Tutorial</strong> <strong>and</strong> <strong>Technical</strong> <strong>Overview</strong>

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

Saved successfully!

Ooh no, something went wrong!