Socket Interface

int sockopen (char * host, int port)

connect up to a socket on host at port. Returns a the fd. Standard system error all apply.

FILE * fopenurl (char * url, int * psts, char * content)

Open a socket to URL url. fopenurl returns a FILE if successful. In all cases, the MIME headers are parsed, but you can optionally capture the HTTP status and the MIME content-type by supply these parameters.

int listenon (char * host, int * startport)

Listen on a socket starting at port startport. The actual port that we're listening on will be returned in startport if we can't bind to that port. The return value is the file desciptor that has been primed to listen.

int accepton (fd, struct sockaddr_in * peer)

The companion of listenon(), wait for an incoming connect request on the listener socket and return the fd of the fully formed connection. Optionally, a peer sockaddr_in can be passed in to gather information about the other side of the connection.

© (copyright) 1997 MTCC
Last modified: Fri Apr 25 20:22:11 PDT 1997