Sockets Flashcards
Winsock API requires linking to what file?
ws2_32.lib
How is the DLL initialized for Winsock API?
WSAStartup()
What 2 parameters are passed to WSAStartup?
- WORD version
- WSAData data
What are the 3 parameters passed to create a socket?
- int addressFamily
- int type
- int protocol
What is the type parameter used when creating a socket for TCP?
SOCK_STREAM
What is the type parameter used when creating a socket for UDP?
SOCK_DGRAM
What is the address family parameter used when creating a socket?
AF_INET
What is the protocol parameter used when creating a socket for TCP?
IPPROTO_TCP
What is the protocol parameter used when creating a socket for UDP?
0
A server should first ______ a socket and then _____ the socket to its address and endpoint.
create, bind
What are the 3 parameters of the bind/connect function?
- SOCKET socket
- sockaddr *socketAddress
- int nameLength
What is the nameLength for a socket?
sizeof(socketAddress)
How do you pass the socketAddress to the bind/connect function?
(SOCKADDR*)&socketAddress
What type is the socketAddress in bind/connect functions?
sockaddr_in
What 3 properties of sockaddr_in do we specify?
- sin_family
- sin_port
- sin_addr