Server / Client commands Flashcards
1
Q
What does socket() do?
A
Creates a socket (an endpoint for communication).
This is for both server and client
2
Q
What does bind() do?
A
Associates the socket with an IP address and port number.
Only for server
3
Q
What does listen() do?
A
Marks the socket as passive, ready to accept incoming connections.
Only for server
4
Q
What does accept() do?
A
Accepts an incoming connection and creates a new socket for communication.
Only for server
5
Q
What does close() do?
A
Closes the socket, releasing its resources.
for both server and client
6
Q
What does connect() do?
A
Connects the client socket to the server’s address. (can read/write after connecting)
only for client