TCP sockets provide a reliable, stream oriented, full duplex connection between two sockets on top of the Internet Protocol (IP). TCP guarantees that the data arrives in order and retransmits lost packets. It generates and checks a per packet checksum to catch transmission errors. TCP does not preserve record boundaries.
Create a TCP connection to host host and set the socket descriptor
in structure sock to the resulting socket. Return
Read all data from sock and call the
function for the socket, if set. Return -1 if the socket has died,
This is the default function for reading from sock.
If the underlying operating system supports urgent data (out-of-band) in
TCP streams, try to send the byte in
sock->oob through the socket
structure sock as out-of-band data. Return zero on success and -1
otherwise (also if urgent data is not supported).