#ifndef SOCK_H #define SOCK_H #include //struct in_addr et sockaddr_in #include //struct hostent, servent, et fonctions get..by... #include //diverses conversions d'adresses #include class Sock{ private: static const int sDom = AF_INET;//domaine adresses static const int sProto = PF_INET;//famille protocoles int sDesc;//descripteur int sType;//type socket DGRAM, STREAM, ... int sRetour;//retour struct sockaddr_in adrSock;//la struct interne qui contient le triplet /*Construction de la structure a partir des donnees nom hote, nom service et protocole local ou distant */ int sockaddLocRempli( const char * nomServ, const char *protoServ); /* Idem mais avec le num'ero de port directement */ int sockaddLocRempli( short numPort); int bind(int desc, const char * nomServ, const char *protoServ); int bind(int desc, short nport); void initparam(); public: /* Constructeur socket sans bind */ Sock(int tip, int protocole=0); /* Constructeur avec bind */ Sock(int tip, const char *nomServ, const char *protoServ, int protocole=0); /* Constructeur avec bind en fournissant un num. port */ Sock(int tip, short nport, int protocole=0); ~Sock(); bool good();//constructeurs OK ? int getsDesc();//retourne le descripteur de socket tout type int getsRetour();//si defaut bind -- par exemple }; #endif