06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

socket pNA+ <strong>System</strong> <strong>Calls</strong><br />

socket Creates a socket.<br />

#include <br />

int socket(<br />

int domain, /* socket domain */<br />

int type, /* socket type carrier */<br />

int protocol /* socket protocol class */<br />

)<br />

Description<br />

Arguments<br />

Return Value<br />

The socket() system call creates a new socket and returns its socket descriptor.<br />

The socket is an endpoint of communication.<br />

domain Specifies the socket domain and must be set to AF_INET.<br />

type Specifies one of the following types of sockets (defined in the<br />

file):<br />

SOCK_STREAM Defines a stream socket, which uses TCP to<br />

provide a reliable connection-based communication<br />

service.<br />

SOCK_DGRAM Defines a datagram socket, which uses UDP to<br />

provide a datagram service.<br />

SOCK_RAW Defines a raw socket, which uses the protocol<br />

specified by protocol for a raw datagram service.<br />

protocol Specifies the network protocol and can be 0, TCP, UDP, or any<br />

other protocol. For raw sockets the protocol can have any value<br />

except TCP or UDP. A protocol number of zero acts as a wildcard<br />

for raw sockets, accepting any raw IP packet.<br />

This system call returns a socket descriptor, or a -1 if an error occurs.<br />

4-76 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

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

Saved successfully!

Ooh no, something went wrong!