TCP Server Code


Description

AuthorAli Rahimi (ali@XCF.Berkeley.EDU)
Organization XCF
DateJun 8, 1996
PurposeProvides routines for writing the network part of a TCP based network server. Uses accessor functions to fit in as seamlessly as possible into the rest of your program without imposing any unnecessary restriction on the structure of your server.
PortabilityPOSIX

Interface

Exported Types
ClientPtrRepresents the state of a client connection. This package accesses the fields of this data structure through accessor functions only.

Exported Functions
FunctionDescription Doc
NetMakeWelcome() Creates a socket that listens for incoming connections. More
NetNewConnection() Waits for a new connection. More
NetCloseConnection() Closes a client's connection. N/A
NetClientDataAvail() Returns the number of bytes available on the connection to a client. N/A
NetGetClientHostname() Gets the hostname of a remote client. More
NetErrStr() Returns a diagnostic message for the last failure. N/A
NetErrNo() Returns a diagnostic number for the last failure. N/A

Source Files

net.cImplementation
net.hInterface
server.hDefinition of the accessors and the ClientPtr type. You are expected to define the functions declared in this file somewhere else and to modify the definition of ClientPtr.

Examples

test.c is test program that emulates a subset of the functionality of the finger daemon. The included server.h file provides an example of how to define ClientPtr and the accessor functions.

Miscellaenous

Using accessors is a good idea. If you don't think so, you are wrong and should go learn how to program.

Download The Package

netserver.tar.gz


Repository@XCF.Berkeley.EDU