Tom Kelliher, CS 318
Mar. 29, 2000
Midterm in one week.
Midterm readings: Chs. 1--5, 7--12, 14--16, 23--25, 29.
Client/server communication diagram, client/server example code.
Midterm review.
server.pl. Note the following:
$!
: errno.
client.pl. Note:
/etc/services
.
Check return values!!!
Create a socket.
socket(SOCKETHANDLE, PF_INET, SOCK_STREAM, getprotobyname("tcp")); setsockopt(SOCKETHANDLE, SOL_SOCKET, SO_REUSEADDR, 1);Parameters:
Bind a socket to a port and IP address.
bind(SOCKETHANDLE, sockaddr_in($sport, INADDR_ANY));Parameters:
Set length of socket's request queue.
listen(SOCKETHANDLE, SOMAXCONN)Parameters:
Wait for and accept a connection request from a client.
accept(CONNECTION, SOCKETHANDLE)Parameters:
sockaddr_in()
to
decode.
Send a message through a socket.
send(CONNECTION, $message, 0);Parameters:
Close a socket.
close(CONNECTION);Parameters:
Connect to a server.
connect(SHANDLE, sockaddr($sport, $sipaddr));Parameters:
Receive a (portion of a) message.
recv(SHANDLE, $message, $length, 0);Parameters:
Re-walk the client/server code at this point.