CPSC 317 Internet Computing: Module 4 (Socket programming with TCP)
bind()
- assigns a port number and IP address to a socket object
listen()
- called by TCP server to convert an unconnected socket (i.e., an active port) into a passive socket (i.e., waiting for incoming connection)
accept()
- called by TCP server to return the next completed connection from the completed connection queue - returns a new socket descriptor
connect()
- called by the client to create a connection with the server - returns when the connection is established or when an error occurs
socket()
- creates a new socket by assigning a new file descriptor - returns the file descriptor, which acts as an index in a file descriptor table and contains pointers to socket information - assigns the protocol to the created socket descriptor
read()
- used in TCP - reads data
write()
- used in TCP - sends data
recvfrom()
- used in UDP - reads data
sendto()
- used in UDP - sends data