Tom Kelliher, CS 318
Mar. 27, 2000
Midterm in one week.
Read 25.1--25.7 (C version of the Perl client/server application.)
Read 24.8.
Read Chapter 29.
Client/server interactions between a web server and a browser.
Continuation of sockets programming, web server project.
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.