Use AF_INET address family

AF_INET address family sockets can be either connection-oriented (type SOCK_STREAM) or they can be connectionless (type SOCK_DGRAM).

Connection-oriented AF_INET sockets use TCP as the transport protocol. Connectionless AF_INET sockets use User Datagram Protocol (UDP) as the transport protocol. When you create an AF_INET domain socket, you specify AF_INET for the address family in the socket program. AF_INET sockets can also use a type of SOCK_RAW. If this type is set, the application connects directly to the IP layer and does not use either the TCP or UDP transports.

Related reference
AF_INET address family
Prerequisites for socket programming
Example: A connection-oriented server
Example: A connection-oriented client