chapter 3 Flashcards
how do computers communicate with each other?
by sending network messages
how do programs send / receive network messages?
through sockets
what is a socket?
is an endpoint in a 2 way communication link between 2 programs running on the same network
what are communication paradigms built from?
sockets
what are the 2 type of networks?
circuit switched and packet switched
what is circuit switching?
is a network that relies on a physical connection b/n 2 nodes for communication
what network guarantees constant QOS?
circuit switching
what is packet switching?
is a network that splits a message into packets to transmit them independently over a digital network
what is internet protocol?
a unique address that identifies a device on a network
what do we mean when we say IP offers no guarantees?
packets may get:
- lost
- delivered twice
- corrupted
- delivered in wrong order
what is UDP?
a transport protocol that does not guarantee the delivery or the ordered delivery of datagrams [ packets ]
what is TPC?
a bidirectional transport protocol that provides reliable [ data ] packet flow b/n devices
how are network addresses represented in UNIX?
a generic struct sockaddr.
- for internet we use sockaddr_in
what is a domain name?
a human readable IP address
what is DNS?
a domain name service translates human readable domain names to machine readable IP address
how is domain name converted to IP?
using : gethostbyname ()
list TCP based protocols?
- TELNET
- FTP
- HTTP
- SMTP
- SSH
in sockets, what are the roles of:
- socket ()
- connect ()
- bind ()
- listen () and
- accept ()
- creates socket
- allows client to initiate a connection to server
- specifies socket id
- listen for a connection
- blocks process til incoming connection is received
what are socket function calls in TCP client side?
socket, connect , write , read, close
what are socket function calls in TCP server side?
socket, bind, listen, accept, read, write, read, close
how are TCP sockets created by default?
as client socket
which type of socket can’t receive incoming connection?
client socket
which type of socket allocates resources for connections?
server socket
how can we convert a client socket to a server socket?
by using listen( ) and specifying how many connections can be supported in parallel
what arguments does the listen() function call take and what does it return?
- sockfd - socket discriptor
- backlog - size of buffer [ limits no of pending connections, not accepted conn]
returns:
- 0 for success and -1 for error
what arguments does the connect() function call take and what does it return?
- sockfd - socket discriptor
- serv_addr - where to connect [ sockaddr_in ]
- addrlen - length of address
returns
- 0 for s -1 for f
which socket function call binds client’s address to a random unused port?
connect( )
what does accept( ) function call do when once a conn is received?
- creates a dedicated socket for it
- old socket goes back to waiting for other conns
what arguments does the accept( ) function call take and what does it return?
- sockfd
- addr - address of client [ sockaddr_in ]
- addrlen
returns:
- descriptor of new socket or -1
what arguments does the write( ) function call take and what does it return?
- sockfd
- buff - buffer to be sent
- count - buffer size
returns:
- no of bytes sent or -1
what arguments does the read( ) function call take and what does it return?
- sockfd
- buff - buffer where to write the read data
- count - buffer size
returns:
- no of bytes read or -1
which socket function call blocks process until data is received from socket?
read( )
for what reason could a write( ) call send less bytes than requested?
- due to limitations of kernel buffer, so always check return bytes and resend unsent data
when does read( ) return 0?
when notifying end of file EOF
what socket function calls block process when executing?
read and accept
what is multiplexing?
is a way of sending multiple signals or streams of information through a socket [ communication link ]
what are the methods to achieve multiplexing?
- using multiple processes
- using non blocking I/O
- using select( )
- using poll( )
how does using multiple processes to achieve multiplexing work?
poorly, consumes resources and is hard to program
how does using non-blocking I/O to achieve multiplexing work?
works for read( ) but not accept( )
how does using select( ) monitor to achieve multiplexing work?
blocks the program until something [ read / write ] happens on the socket
how does using poll( ) to achieve multiplexing work?
similarly to select( ), but provides additional info about streams
list structures of a server?
- iterative
- 1 child / client
- pre-forked
- select loop
briefly explain iterative server structure.
- 1 req after another
- long queue [ accept( ) ]
- higher latency
- low resource utilization
briefly explain 1 child / client server structure.
- new process created for every conn
- concurrent handling of requests
- not suitable for highly loaded servers
which server structure is the most common among concurrent servers?
1 child / client
briefly explain per-forked server structure.
- server creates pool of processes
- good for highly loaded servers
- allows limitation on num of processes created
how does the pre-forked server variant work?
with thread pools instead of process pools
what is the downside of pre-forked servers?
- accept( ) requires the use of synchronization
lockmutex( ) -> accept( ) -> unlockmutext( )
briefly explain select loop server structure.
- difficult to do correctly
- read more man idk