Links Powered by MicMac
Cocoa-C-Porting
Fink's translation team
Mac OSX, Fink and Unix
Client/Server Architecture
PowerPC Architecture - UML
System programming
Merise
Pierre-Loïc and Pascaline's wedding

Server Reference

Last modified: 22/04/2004 05:21:40 CEST
Author: Michèle Garoche contact

Contents - Overview - Diagrams - Client documentation - Server documentation - Functions documentation - Headers documentation - Client source code - Server source code - Functions source code - Headers source code -

tcpserv.c File Reference

Server module. More...

Go to the source code of this file.

Includes

"wrapsock.h"

Functions

int main (int argc, char *argv[])
Main entry in server module.

Variables

int listenfd
passive socket's file descriptor.

int connfd
active socket's file descriptor for child process.

int chopt
dummy variable for options test.

int port_served = 0
port to connect.

int childpid
pid of the child process.

socklen_t clilen
size of the client's address structure.

char progname [MAXLINE]
program's name.

struct sockaddr_in cliaddr
structure of client's socket address.

struct sockaddr_in servaddr
structure of server's socket address.


Detailed Description

Server module.

Usage

example: ./tcpserv -a

Features

Check the arguments supplied by the user

Retrieve the program's name

Check if 2 arguments were supplied, if not display help message and quit

Check if the option supplied is a valid one, if not display help message and quit

Compute the real port number

Check if port was supplied with a dash before it, if not display help message and quit

Print an help message on the terminal io

Create an active socket

Fill in the address structure, if address supplied not valid, display help message and quit

Bind the socket

Convert the active socket into passive socket

Set up a signal to catch SIGCHILD

Loop and wait for clients to connect

Handle client connection

Fork a process which handles the client's request

Parent closes the connected socket

Definition in file tcpserv.c.


Function Documentation

int main (int argc, char *argv[])
Main entry in server module.

Parameters:
argc => number of arguments.
argv[] => value of arguments.
Returns:
status of exit to the system when quitting.

Definition at line 41 of file tcpserv.c.

References: childpid, cliaddr, clilen, connfd, chopt, listenfd, port_served, progname[MAXLINE], servaddr
Bind(), Close(), err_sys(), Fork(), Listen(), servusage(), sig_chld(), Signal(), Socket() .


Generated on Sat Mar 1 04:09:03 2003 for tcpcliserv by doxygen


Contents - Overview - Diagrams - Client documentation - Server documentation - Functions documentation - Headers documentation - Client source code - Server source code - Functions source code - Headers source code -

Powered by Apache/1.3.41 (Darwin) PHP/4.4.8 on Mac OS X bluefish distributed.net Cssed icon Conglomerate icon Valid HTML 4.0.1 Valid CSS
Local date (dd/mm/yyyy): 29/08/2008 06:12:09 CEST