When I execute next program, the client stops
in the middle of the loop ( about i = 1000 ).
The error message is
Error in XmlRpcClient::doConnect: Could not connect to server (error 24).
Please help me.
=====================Server Program ====================
class GetID : public XmlRpcServerMethod {
public:
GetID(XmlRpcServer* s);
void execute(XmlRpcValue& params, XmlRpcValue& result){
result=getID();
}
string getID();// only return string "dummy"
};
int main(int argc, char* argv[]) {
XmlRpcServer s;
GetID getid(&s);
const int PORT = 8881;
s.bindAndListen(PORT);
s.work(-1.0);
return 0;
}
I dont know. Apparently something is not being cleaned up properly since it looks like your clients
are being closed (you didn't post the client code so Im just assuming the IDManager is an XmlRpcClient).
I will try it here & let you know.
By the way, you can look up the error code (24) in errno.h or similar on your system.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2003-06-05
Thank you for answering my question.
My test sources are the next.
=====================Server Program ====================
class GetID : public XmlRpcServerMethod {
public:
GetID(XmlRpcServer* s) XmlRpcServerMethod("getID", s){}
void execute(XmlRpcValue& params, XmlRpcValue& result){
result=getID();
}
string getID() { return "dummy";}
};
int main(int argc, char* argv[]) {
XmlRpcServer s;
GetID getid(&s);
const int PORT = 8881;
s.bindAndListen(PORT);
s.work(-1.0);
return 0;
}
Hello.
When I execute next program, the client stops
in the middle of the loop ( about i = 1000 ).
The error message is
Error in XmlRpcClient::doConnect: Could not connect to server (error 24).
Please help me.
=====================Server Program ====================
class GetID : public XmlRpcServerMethod {
public:
GetID(XmlRpcServer* s);
void execute(XmlRpcValue& params, XmlRpcValue& result){
result=getID();
}
string getID();// only return string "dummy"
};
int main(int argc, char* argv[]) {
XmlRpcServer s;
GetID getid(&s);
const int PORT = 8881;
s.bindAndListen(PORT);
s.work(-1.0);
return 0;
}
=============Client Program============================
int main(){
for(int i=0;i<3000;i++){
IDManager im("ServerName",8881);
str=im.getID();
cerr<<i<<str<<endl;
}
}
return 0;
}
I dont know. Apparently something is not being cleaned up properly since it looks like your clients
are being closed (you didn't post the client code so Im just assuming the IDManager is an XmlRpcClient).
I will try it here & let you know.
By the way, you can look up the error code (24) in errno.h or similar on your system.
Thank you for answering my question.
My test sources are the next.
=====================Server Program ====================
class GetID : public XmlRpcServerMethod {
public:
GetID(XmlRpcServer* s) XmlRpcServerMethod("getID", s){}
void execute(XmlRpcValue& params, XmlRpcValue& result){
result=getID();
}
string getID() { return "dummy";}
};
int main(int argc, char* argv[]) {
XmlRpcServer s;
GetID getid(&s);
const int PORT = 8881;
s.bindAndListen(PORT);
s.work(-1.0);
return 0;
}
=============Client Program============================
class IDManager {
public:
IDManager(string uri, int p) {
serverUri = uri; port = p;
}
string getID(){
XmlRpcClient c(serverUri.c_str(), port);
XmlRpcValue noArgs, result;
if(c.execute("getID", noArgs, result)){
return result;
};
private:
string serverUri;
int port;
};
int main(){
for(int i=0;i<3000;i++){
IDManager im("ServerName",8881);
str=im.getID();
cerr<<i<<str<<endl;
}
}
return 0;
}
>By the way, you can look up the error code (24) in errno.h or similar on your system.
My system is RedHat Linux 7.3 and gcc 3.2 .
I find
#define EMFILE 24 /* Too many open files */
in /usr/include/ams/error.h
The client socket is not being closed, so the server is keeping its end open as well.
The destructor for XmlRpcClient should close its socket, something like this:
XmlRpcClient::~XmlRpcClient() {
close();
}
I will put a fix into cvs.
Chris
Hi Chris,
My problem is solved perfectly.
Thank you very much for your kind advice.