Socket in computer network Flashcards
What is a socket?
1 endpoint of a 2 way communication link between 2 programs running on a network.
Each socket has a specific address, composed of an IP and a port
How is a connection established with the socket technique?
- Server creates socket, attaches it to a network port addres,
- then waits for the client to contact it
- client creates a socket, then attempts to connect to the server socket
- when connection is established -> data transfer takes place
Name the 2 types of sockets
Datagram socket
Stream socket
What is a datagram socket?
Type of network which has connection less points for sending and receiving packets. (Similar to mailbox
-> The letters (data) posted into the box are collected and delivered (transmitted) to a letterbox (receiving socket) )
What is a stream socket?
- Type of network socket which provides a connection-oriented,
sequenced, and unique flow of data - without record boundaries
- with well defined mechanisms for creating and
destroying connections and for detecting errors. (Similar to phone
-> Connection is established between the phones (two ends) and a conversation (transfer of data) takes place.
What parameter to the sock function is used to store IPv4 address?
socket.AF_INET
What parameter to the sock function is used to store the protocol (tcp)?
sock.SOCK_STREAM