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

Headers Source Code

Last modified: 22/04/2004 05:21:41 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 -

wrapsock.h

Go to the documentation of this file.

00001 /* wrapsock.h */
00002 /* Functions wrapper headers */
00003 /* To be used with tcpcli.c and tcpserv.c
00004 /* Author: Michèle Garoche */
00005 /* Date: February 26th 2003
00006 /* Feel free to do what you want with it */
00007 
00171 #ifndef __wrapsock_h
00172 #define __wrapsock_h
00173 
00174 /* Includes */
00175 /* fprintf, snprintf, strerror, fflush, fputs, sscanf,
00176 fgets, ferror, printf, vsnprintf, fileno, stdout, stderr, FILE, EOF  */
00177 #include <stdio.h>
00178 /* exit, EXIT_SUCCESS, EXIT_FAILURE */
00179 #include <stdlib.h>
00180 /* accept, connect, bind, listen, socket, shutdown, SHUT_WR */
00181 #include <sys/socket.h>
00182 /* strcpy, bzero, strlen, strcat, strerror */
00183 #include <string.h> 
00184 /* getpid, getopt, fork, read, close, write, select */
00185 #include <unistd.h> 
00186 /* errno, EINTR */
00187 #include <sys/errno.h>
00188 /* htons, htonl, inet_pton */
00189 #include <arpa/inet.h> 
00190 /* storage size of struct address, INADDR_ANY */
00191 #include <netinet/in.h> 
00192 /* va_list, va_start, va_end */
00193 #include <stdarg.h> 
00194 /* syslog, LOG_ERR */
00195 #include <syslog.h> 
00196 /* waitpid, WNOHANG */
00197 #include <sys/wait.h> 
00198 /* pow */
00199 #include <math.h> 
00200 /* isupper, isdigit, tolower */
00201 #include <ctype.h> 
00202         
00203 /* Not included, maybe should be on other systems */
00204 /*#include <sys/types.h> in_addr_t, in_port_t, pid_t,
00205 ssize_t, fd_set, FD_ZERO, FD_ISSET, FD_CLR normally included by stdio */
00206 /*#include <signal.h> sigaction normally included by unistd */
00207 /*#include <sys/syslimits.h> normally included by limits */
00208 /*#include <limits.h> normally included by socket*/
00209 /*#include <sys/time.h> timeval normally included by types */
00210 
00211 /* Extern globals */
00212 /* Used by geopt to check the options supplied by the user */
00213 extern char *optarg; /* option argument */
00214 extern int optind; /* index of the next argument on return */
00215 extern int optopt; /* last known option on return */
00216 extern int opterr; /* error on return */
00217 extern int optreset; /* not used here */
00218 
00219 /* Defines */
00220 /* defined before the right type get a chance to be defined */
00221 #define socklen_t unsigned int
00222 /* port to handle all requests */
00223 #define SERV_PORT1 9877 
00224 /* port to handle numeric requests */
00225 #define SERV_PORT2 9878 
00226 /* port to handle word conversion */
00227 #define SERV_PORT3 9879 
00228 /* length of a line */
00229 #define MAXLINE 4096 
00230 /* maximum number of pending connections */
00231 #define LISTENQ 128 
00232 /* convenience to make it easier to read the code */
00233 #define SA struct sockaddr
00234 /* returns the maximum of a and b */
00235 #define MGMAX(a,b) (((a) > (b)) ? (a) : (b)) 
00236 
00237 /* Typedefs */
00238 /* Convenient definition to make it easier to read the code */
00239 typedef void Sigfunc(int);
00240 
00241 /* Functions protocols */
00242 
00243 /* Used by client */
00244 void cliusage(char *);
00245 void Inet_pton(int, const char *, void *);
00246 void Connect(int, const struct sockaddr *, socklen_t);
00247 void str_cli(FILE *, int);
00248 
00249 /* Used by server */
00250 void servusage(char *);
00251 void Bind(int, const struct sockaddr *, socklen_t);
00252 void Listen(int, int);
00253 Sigfunc *Signal(int, Sigfunc *);
00254 pid_t Fork(void);
00255 void Close(int);
00256 void str_serv1(int);
00257 void str_serv2(int);
00258 void str_serv3(int);
00259 
00260 /* Used by client and server */
00261 int Socket(int, int, int);
00262 
00263 /* Used to read a line */
00264 char * Fgets(char *, int, FILE *);
00265 ssize_t mg_readline(int, void *, size_t);
00266 ssize_t Readline(int, void *, size_t);
00267 
00268 /* Used to write a line */
00269 void Fputs(const char *, FILE *);
00270 ssize_t writen(int, const void *, size_t);
00271 void Writen(int, void *, size_t);
00272 
00273 /* Used to handle SIGCHLD */
00274 Sigfunc * mg_signal(int, Sigfunc *);
00275 
00276 /* Used to wait on requests */
00277 int Select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
00278 
00279 /* Used to close the socket in  child process */
00280 void Shutdown(int, int);
00281 
00282 /* Used to handle errors */
00283 void err_sys(const char *fmt, ...);
00284 void err_quit(const char *fmt, ...);
00285 
00286 #endif
00287 /* end of wrapsock.h */


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:14:30 CEST