In the current stand, there is not way to know the client IP inside an execute call, but, hey, we are talking about a C++ DLL.
These are a few ideas you can implemente, but not all tested and do not know if it is the better design. Anyway, notice that:
1. Executing a server method needs to call child classes of XmlRpcServerMethod, i.e, MyMethodXmlRpcServerMethod
2. Each XmlRpcServerMethod object has a reference to the XmlRpcServer object
3. But the client information is part of the XmlRpcServerConnection class. As parameter of this class constructor, it is the connection socket.
4. Objects of XmlRpcServerConnection are created by connection incoming
5. When a XML RPC message comes into a server connection object, it looks for the matching method and call the 'execute' function
you can do following:
1. Create a child of XmlRpcServerConnection, i.e. XmlServerConnectionIPStoring. Use the same constructor as XmlRpcServerConnection and add one more data attribute, called std::string peerIP. When an object is instansiated (using the constructor), use getpeername and inet_ntoa to get the client IP
2. To let the method object know with server client call it, you can use the following:
2.1. Create a child of XmlRpcServerMethod, i.e. XmlRpcServerMethodWithIP, with one more attribute called clientIP. Then, you can create a function XmlRpcServerMethodWithIP::setClientIP.
2.2. In XmlServerConnectionIPStoring, overload the method executeMethod. Add the call to XmlRpcServerMethodWithIP::setClientIP.
2.3. All children of XmlRpcServerMethodWithIP (i.e. MyMethodXmlRpcServerMethodWithIP) can in the ::execute method access the value of the clientIP value
It sounds much more complicated as (IMHO) it is
Let me know if you need more inputs and if you implement the feature or not
Quique
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
i have made a server
which has few functions
i want to know whats the client IP whenever some client calls a function at server
how can i get client IP in function at server
anybody here
waiting for your reply
In the current stand, there is not way to know the client IP inside an execute call, but, hey, we are talking about a C++ DLL.
These are a few ideas you can implemente, but not all tested and do not know if it is the better design. Anyway, notice that:
1. Executing a server method needs to call child classes of XmlRpcServerMethod, i.e, MyMethodXmlRpcServerMethod
2. Each XmlRpcServerMethod object has a reference to the XmlRpcServer object
3. But the client information is part of the XmlRpcServerConnection class. As parameter of this class constructor, it is the connection socket.
4. Objects of XmlRpcServerConnection are created by connection incoming
5. When a XML RPC message comes into a server connection object, it looks for the matching method and call the 'execute' function
you can do following:
1. Create a child of XmlRpcServerConnection, i.e. XmlServerConnectionIPStoring. Use the same constructor as XmlRpcServerConnection and add one more data attribute, called std::string peerIP. When an object is instansiated (using the constructor), use getpeername and inet_ntoa to get the client IP
2. To let the method object know with server client call it, you can use the following:
2.1. Create a child of XmlRpcServerMethod, i.e. XmlRpcServerMethodWithIP, with one more attribute called clientIP. Then, you can create a function XmlRpcServerMethodWithIP::setClientIP.
2.2. In XmlServerConnectionIPStoring, overload the method executeMethod. Add the call to XmlRpcServerMethodWithIP::setClientIP.
2.3. All children of XmlRpcServerMethodWithIP (i.e. MyMethodXmlRpcServerMethodWithIP) can in the ::execute method access the value of the clientIP value
It sounds much more complicated as (IMHO) it is
Let me know if you need more inputs and if you implement the feature or not
Quique
thanks for the reply
i am getting back to this topic after a long time
i will let you know and post code here if i am able to do it