Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

my_sockets.h

Go to the documentation of this file.
00001 /*! \file my_sockets.h
00002     Header file for sockets.c.
00003  */
00004 
00005 #ifdef __cplusplus
00006 extern "C" {
00007 #endif 
00008 
00009 
00010 #ifndef SOCKETS_H
00011 
00012   #include <stdio.h>
00013   #include <stdlib.h>
00014   #include <unistd.h>
00015   #include <string.h>
00016   #include <sys/types.h>
00017   #include <sys/socket.h>
00018   #include <netdb.h>
00019   #include <netinet/in.h>
00020   #include <sys/param.h>
00021   #include <arpa/inet.h>
00022 
00023 
00024   int open_tcp_connexion (struct sockaddr_in*, char*, int, long, long, unsigned long int*);
00025   void Get_Sock_Adress (char *Machine_serveur, int port_serveur, struct sockaddr_in *TCP_address);
00026   int read_from_socket (int sockfd, char *buffer, size_t buffer_size, size_t* extracted, long tt_sec, long tt_micro, unsigned long int* ellapsed_time);
00027   int read_all_socket (int sockfd, char** buffer, long tt_sec, long tt_micro, unsigned long int* ellapsed_time, unsigned long int* size);
00028 
00029   /* ----------------------------------------------------------- */
00030   /* Buffer sizes                                                */
00031   /* ----------------------------------------------------------- */
00032 
00033   /*! \brief Initial number of bytes for the buffer used to read data from a socket.
00034    */
00035   #define SCK_BUFFER_INIT_SIZE           1024
00036 
00037   /* ----------------------------------------------------------- */
00038   /* Error codes for open_tcp_connexion()                        */
00039   /* ----------------------------------------------------------- */
00040 
00041   /*! \brief Return value for the function open_tcp_connexion(). This means that the process can not create a new socket
00042              (in other words, the system call socket() failed).
00043    */
00044   #define SCK_CREATE_ERROR              -1
00045 
00046   /*! \brief Return value for the function open_tcp_connexion(). This means that the process can not connect to the remote
00047              server. In other words, the function connect() failed.
00048    */
00049   #define SCK_CONNECT_ERROR             -2
00050 
00051   /*! \brief Return value for the function open_tcp_connexion(). This means that the process can not get the IP address of
00052       the host running the remote server. In other words, the function gethostbyname() failed.
00053    */
00054   #define SCK_GET_IP_ERROR              -3
00055 
00056   /*! \brief Return value for the function open_tcp_connexion(). This means that the system call connect() has been
00057       interrupted by a signal (it should be SIGALRM.
00058    */  
00059   #define SCK_TIMEOUT_CONNECT           -4
00060 
00061   /*! \brief Return value for the function open_tcp_connexion(). This means that there was a problem with the high precision timer (that
00062              raises the signal SIGALRM). This error should not happen.
00063    */
00064   #define SCK_TIMER_ERROR               -5
00065 
00066   /*! \brief Return value for the function open_tcp_connexion(). This means that there was a problem with the high precision chronometer
00067    */
00068   #define SCK_CHRONO_ERROR              -6
00069 
00070   /* ----------------------------------------------------------- */
00071   /* Error codes fro read_all_socket() and read_from_socket()    */
00072   /* ----------------------------------------------------------- */
00073 
00074   /*! \brief Return value for the function read_all_socket() and read_from_socket(). This means that the function was successful.
00075    */
00076   #define SCK_READ_OK                   -7
00077 
00078   /*! \brief Return value for the function read_all_socket(). This means that the function can not allocate memory to store the data read
00079              from the socket.
00080    */
00081   #define SCK_READ_NO_MEM               -8
00082 
00083   /*! \brief Return value for the function read_all_socket() and read_from_socket(). This means that the function failed on the read()
00084              system call.
00085    */
00086   #define SCK_READ_READ_ERROR           -9
00087 
00088   /*! \brief Return value for the function read_all_socket() and read_from_socket(). Read timeout!
00089    */
00090   #define SCK_READ_TIMEOUT              -10
00091 
00092   /*! \brief Return value for the function read_all_socket() and read_from_socket(). This means that there was a problem with the high
00093              precision chronometer.
00094    */
00095   #define SCK_READ_CHRONO_ERROR         -11
00096 
00097   /*! \brief Return value for the function read_all_socket() and read_from_socket(). This means that there was a problem with the high
00098              precision timer.
00099    */
00100   #define SCK_READ_TIMER_ERROR          -12
00101 
00102   #define SOCKETS_H
00103 
00104 
00105 #endif /* SOCKETS_H */
00106 
00107 
00108 #ifdef __cplusplus
00109 }
00110 #endif

Generated on Thu Apr 3 16:23:43 2003 for Common_C_libraries by doxygen1.3-rc1