Ch. 7 - Message Passing Flashcards
What steps must be taken for a server to communicate with a client?
- socket()
- bind()
- listen()
- accept()
- read()/write() (until transaction complete)
- shutdown()/close()
What steps must be taken for a client to communicate with a server?
- socket()
- connect()
- write()/read() (until transaction is complete)
- shutdown()/close()
Why is message passing generally easy to implement?
Reading/writing messages between sockets works in the same way that read()/write() work for files (easy to implement for files)! In fact, a socket is just a file descriptor.
Why does TCP/IP break data into packets?
Packet size is well defined. Thus, no assumptions have to be made about the size of the message since the message can be partitioned into many small packets.
Does TCP/IP ensure that messages arrive in order?
No, TCP/IP cannot guarantee that messages arrive in order. TCP/IP reassembles the packets received so that the entire message is in the correct order.
If we want fast message passing and are willing to accept some errors, should we use TCP or UDP?
Use UDP. UDP requires less overhead because it does not do error checking. Thus, UDP is faster than TCP.
socket()
Create a socket used for message passing
Ports
Determine which process to send a message to. Required to send a message since there are many processes that receive messages.
bind()
Declares address where messages sent to socket should go.
listen()
Allow incoming connections and set a limit for the maximum incoming connections.
accept()
Wait for a message and accept the connection
close()
Deallocate the file descriptor specified
select()
Monitor multiple file descriptors waiting until one or more of the file descriptors become “ready” for some I/O operation.