Commit 7ac3a5ab authored by Reza  ANSARI's avatar Reza ANSARI
Browse files

changement ordre des arguments du constructeur UDPServerSocket pour permettre...

changement ordre des arguments du constructeur UDPServerSocket pour permettre argument par defaut nullptr, Reza
parent 58319b53
......@@ -669,29 +669,22 @@ ostream& ClientSocket::Print(ostream & os) const
*/
/* --Methode-- */
UDPServerSocket::UDPServerSocket(int port)
UDPServerSocket::UDPServerSocket(int port, const char* inadr)
: Socket()
{
Initialize(NULL, port);
Initialize(port, inadr);
}
/* --Methode-- */
UDPServerSocket::UDPServerSocket(const char* inadr, int port)
UDPServerSocket::UDPServerSocket(int port, string const& inadr)
: Socket()
{
Initialize(inadr, port);
}
/* --Methode-- */
UDPServerSocket::UDPServerSocket(string const& inadr, int port)
: Socket()
{
Initialize(inadr.c_str(), port);
Initialize(port, inadr.c_str());
}
/* --Methode-- */
void UDPServerSocket::Initialize(const char* str_inadr, int port)
void UDPServerSocket::Initialize(int port, const char* str_inadr)
{
int s,rc;
s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
......
......@@ -178,14 +178,13 @@ protected:
class UDPServerSocket : public Socket
{
public :
UDPServerSocket(int port);
UDPServerSocket(const char* inadr, int port);
UDPServerSocket(string const& inadr, int port);
UDPServerSocket(int port, const char* inadr=nullptr);
UDPServerSocket(int port, string const& inadr);
virtual int Close(); // redefinition de la methode de Socket::Close()
virtual ostream& Print(ostream & os) const;
protected:
void Initialize(const char* inadr, int port);
void Initialize(int port, const char* inadr);
int portid;
struct sockaddr_in ipskt;
......
......@@ -306,9 +306,7 @@ int serverside(const char* adr, bool fgudp)
ServerSocket* psrvT=nullptr;
UDPServerSocket* psrvU=nullptr;
if (fgudp) {
if (adr) psrvU = new UDPServerSocket(adr, PORTID);
else psrvU = new UDPServerSocket(PORTID);
psrvU = new UDPServerSocket(PORTID, adr);
}
else {
if (adr) psrvT = new ServerSocket(adr, PORTID, 1);
......@@ -732,7 +730,7 @@ int fproc_server_client(string &servname, string& args, bool fgudp)
if (cpid!=0) { // this is the parent process
cout << "==== This is the Parent process PID="<<getpid()<<" running server..."<<endl;
rcs= serverside(nullptr, fgudp);
cout << "==== End of the Child process "<<endl;
cout << "==== End of the Parent process "<<endl;
return rcs;
}
else { // this is the Child process
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment