Test Class Reference

Classe de test des sockets TCP et UDP. More...

#include <Test.h>

List of all members.

Public Member Functions

 Test ()
void TestUDP () const
void TestTCP () const

Private Member Functions

void ClientUDP (unsigned int port) const
void ServeurUDP (unsigned int port) const
void ClientTCP (unsigned int port) const
void ServeurTCP (unsigned int port) const


Detailed Description

Classe de test des sockets TCP et UDP.

Definition at line 35 of file Test.h.


Constructor & Destructor Documentation

Test::Test (  )  [inline]

Definition at line 37 of file Test.h.

00037 {}


Member Function Documentation

void Test::TestUDP (  )  const [inline]

Definition at line 38 of file Test.h.

References ClientUDP(), and ServeurUDP().

00038                             {
00039                 cout<<"Test Client/Serveur UDP (fork)"<<endl;
00040                 unsigned int port=7777;
00041                 if(fork()){
00042                         //Père (SERVEUR)
00043                         ServeurUDP(port);
00044                 } else {
00045                         //Fils (CLIENT)
00046                         sleep(5); //On laisse le temps au serveur de se lancer
00047                         ClientUDP(port);
00048                 }
00049         }

Here is the call graph for this function:

void Test::TestTCP (  )  const [inline]

Definition at line 51 of file Test.h.

References ClientTCP(), and ServeurTCP().

00051                             {
00052                 cout<<"Test Client/Serveur TCP (fork)"<<endl;
00053                 unsigned int port=7777;
00054                 if(fork()){
00055                         //Père (SERVEUR)
00056                         ServeurTCP(port);
00057                 } else {
00058                         //Fils (CLIENT)
00059                         sleep(5); //On laisse le temps au serveur de se lancer
00060                         ClientTCP(port);
00061                 }
00062         }

Here is the call graph for this function:

void Test::ClientUDP ( unsigned int  port  )  const [inline, private]

Definition at line 65 of file Test.h.

References Socket::Ecouter(), and Socket::Envoyer().

Referenced by TestUDP().

00065                                                {
00066                 Socket *c=new SocketUDP("localhost",(unsigned int)port);
00067                 cout<<"Client: >>:Bonjour"<<endl;
00068                 c->Envoyer("Bonjour");
00069                 cout<<"Client: <<: "<<c->Ecouter()<<endl;
00070                 cout<<"Client: >>:Très bien et vous?"<<endl;
00071                 c->Envoyer("Très bien et vous?");
00072                 delete c;
00073         }

Here is the call graph for this function:

void Test::ServeurUDP ( unsigned int  port  )  const [inline, private]

Definition at line 75 of file Test.h.

References Socket::Ecouter(), and Socket::Envoyer().

Referenced by TestUDP().

00075                                                 {
00076                 Socket *s=new SocketUDP((unsigned int)port); //+bind
00077                 cout<<"Serveur: Attente d'une connexion"<<endl;
00078                 cout<<"Serveur: <<: "<<s->Ecouter()<<endl;
00079                 s->Envoyer("ça va?");
00080                 cout<<"Serveur: >>: ça va?"<<endl;
00081                 cout<<"Serveur: <<: "<<s->Ecouter()<<endl;
00082                 delete s;
00083         }

Here is the call graph for this function:

void Test::ClientTCP ( unsigned int  port  )  const [inline, private]

Definition at line 86 of file Test.h.

References Socket::Ecouter(), and Socket::Envoyer().

Referenced by TestTCP().

00086                                                {
00087                 Socket *c=new SocketTCP("localhost",(unsigned int)port);
00088                 sleep(1);
00089                 unsigned int i=0;
00090                 while(1){
00091                 cout<<i<<endl;
00092                 cout<<"Client: >>:Bonjour"<<endl;
00093                 c->Envoyer("Bonjour");
00094                 cout<<"Client: <<: "<<c->Ecouter()<<endl;
00095                 cout<<"Client: >>:ien et vous?"<<endl;
00096                 c->Envoyer("vvvvvvvvvvvvvvvvvvvvvvvvvvffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv");
00097                 i++;
00098                 }
00099                 delete c;
00100         }

Here is the call graph for this function:

void Test::ServeurTCP ( unsigned int  port  )  const [inline, private]

Definition at line 101 of file Test.h.

References Socket::Accept(), Socket::Ecouter(), and Socket::Envoyer().

Referenced by TestTCP().

00101                                                 {
00102                 Socket *s=new SocketTCP((unsigned int)port); //+bind+listen
00103                 cout<<"Serveur: Attente d'une connexion"<<endl;
00104                 Socket *ecoute=s->Accept();
00105                 while(1){
00106                 cout<<"Serveur: <<: "<<ecoute->Ecouter()<<endl;
00107                 ecoute->Envoyer("ça vssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss");
00108                 cout<<"Serveur: >>: ça va?"<<endl;
00109                 cout<<"Serveur: <<: "<<ecoute->Ecouter()<<endl;
00110                 }
00111                 delete ecoute;
00112                 delete s;
00113         }

Here is the call graph for this function:


The documentation for this class was generated from the following file:
Generated on Wed Jan 2 14:02:16 2008 for Pacman by  doxygen 1.5.1