Use the socket function to create a socket. The socket type is defined in Winsock. h:
Socket socket (int af, int type, int Protocol );
AF is the Protocol address family. Here we use IPv4, which must be af_inet
Type is socket type. If TCP/IP is used, type is set to sock_stream. If UDP is used, sock_dgram is used.
Protocol is used to limit specific transmission when multiple entries are provided for the given address family and socket type. For TCP, its value is ipproto_tcp, while UDP is ipproto_udp.
Winsock uses the setsockopt, getsockopt, ioctlsocket, and wsaioctl functions to control various socket options and behaviors. For simple Winsock applications, we may not need to use them. once a socket is successfully established, you can prepare to send and receive data through the socket. winsock has two communication modes: connection-oriented communication mode and connectionless communication mode.