Network Programming Flashcards
TCP
Transmission Control Protocol
Prevents errors with package loss, out of order, duplicated, etc.
UDP
User Datagram Protocol
Provides no protection against package errors
Socket
An application can use a socket to communicate with another process - can be used like a file to read/write to
AF_UNIX domain
Used for local communication
AF_INET, AF_INET6
INET for IPv4 internet protocols, INET6 for IPv6 internet protocols
IPv4 vs IPv6
IPv4 uses 32 bit IP address, IPv6 uses 128 bit IP addresses
TCP Server Socket Sequence
- socket
- bind
- listen
- accept.
- read
- write
- close
UDP Client Socket Sequence
- socket
- connect
- write
- read
bind()
binds a socket to an address, used by server
listen()
marks the socket as passive, used to wait for a connection to come
accept()
returns a new connection, i.e. a new socket to use for connection
connect()
connect to passive socket, used by client
Connection-oriented
make a connection first before transmitting any data
UDP server socket sequence
- socket
- bind
- recvfrom
- sendto
- close
sendto, recvfrom vs. read, write
read, write are universal file descriptor functions, the others are socket-specific