70 likes | 192 Views
Internet and Intranet Protocols and Applications. Lecture 4: Internet Servers Feb 15, 2000 Arthur P. Goldberg Clinical Associate Professor of Computer Science and Information Systems New York University artg@cs.nyu.edu. Server design issues. Functionality
E N D
Internet and Intranet Protocols and Applications Lecture 4: Internet Servers Feb 15, 2000 Arthur P. Goldberg Clinical Associate Professor of Computer Science and Information Systems New York University artg@cs.nyu.edu
Server design issues • Functionality • Handle multiple clients concurrently • Maintaining client-specific state at a server (usually) • Reduce message sizes • Require fault-tolerance • Access control • Authenticate clients • Evaluate whether client is allowed access • Secure data • Robustness • Performance • Reliability
Server Socket Calls rc = bind(socket,(struct sockaddr *) localaddr, addrlen); • Specify local IP:port rc = listen(socket, queuelen); • TELL socket to queue up to queuelen REQUEST retcode=accept(socket, (struct sockaddr*) addr, (int *)addrlen); • wait until connection REQUEST arrives; return descriptor of new connected socket. [datatypes int unless otherwise specified]
Fork rc=fork(); • duplicate process; return 0 to child, child PID to parent.
Select #include <sys/types.h> #include <sys/time.h> int select (width, readfds, writefds, exceptfds, timeout); int width; fd_set *readfds, *writefds, *exceptfds; struct timeval *timeout; • wait for first fd in a set to become ready, or a timeout.
Precise description of stateful server challenge • Idempotent • An operation which can be applied multiple times and still produce the same result • Formally, operation O is idempotent iff • O( a ) = O( O( a ) ) • Example • Idempotent: x = z • Not idempotent: x = x +z • In a stateful server • Request operations must be idempotent, or • The server must recover from failures
Comer advice • If the network is unreliable or machines can crash then the server should be stateless • I disagree: I think we need to make stateful servers, because they provide greater functionality; therefore, they must be fault-tolerant