Menu

How to detect presence/absence of a server

Help
2007-07-09
2013-04-24
  • Eric Bracken

    Eric Bracken - 2007-07-09

    Suppose I am writing an XmlRpc++ client, and I want to determine if the server is running and listening for requests.  What is the correct, robust way to do this?

    (Just trying to execute() seems to crash the client app if the server isn't there.)

    Thanks!

     
    • quique123

      quique123 - 2007-07-17

      If you use that method (just call the an execute function), XmlRpc++ client does not crash, at least not how I use the lib. Try to explain the whole environment (OS, compiler, etc) a little bit more in detailed.

      Another option to detect it is ping the server, to check if the server is reachable.

      José

       
    • SE1

      SE1 - 2008-01-24

      My client app also crashes if I just call execute.  Windows XP, MS Visual Studio 2003.

      Is there any way to patch the library so that xmlrpc-c++ will send non-blocking commands?

       
    • quique123

      quique123 - 2008-01-29

      Maybe you can describe a little bit more detailed what you mean with "My client app also crashes..." How does it crash? Can you put some source code here and tell me in which line the software crashes?

      Just some guesses:

      - You create a client object (XmlRpcClient) and use it to call a remote procecure in the server.
      - To do it, you declare a couple of XmlRpcValue's and give them as parms in the execute () function
      - XmlRpcValue's are not initialized before calling execute ()
      - Then, you try to evaluate the return value (XmlRpcValue that you use as "return"), without checking the return value of the execute ()
      - If the sever is not connected, the application crashes (unhandled exception)

      If I am right, you should initialize your "result" value and check the return of the execute () procedure

      As info, if the client is not connected with the server, the first time you call an execute command, the connection will be stablish. And that is done using a open socket command, blocking. If you want to change it, you need to change the XmlRpc++ lib (if you really want it, I can help you)

      But IMHO, use another approach than change the open command to check if the server is running.

      José

       
  • Dragonyte

    Dragonyte - 2010-03-23

    I also have the crashing problem but here are all the details :
    1. I use Visual Studio 2008 to compile the library.
    2. The error only occurs in debug mode and not in release mode
    3. The error is an exception thrown after an assert in std::list is violated.
    4. This assert is on the use (derefrencing) of an iterator "thisIt" in the XmlRpcDispatch::work method

    What happens in the work method is that if a client is trying to connect to a server which is not there then he succeeds in writing the message but then fails in reading the header. when failing to read it closes the current socket and the calls the "setupConnection" method which takes the source out of the dispatcher sources list and puts it back in (why exactly ?).
    This remove & add sequence invalidates the iterator (but the iterator is still actually pointing in the right way) and causes the exception.

    My question is why does it happen ? and only in debug mode ?
    is it promised that the iterator will always point to the right source after the remove&add ?
    does it matter what compiler I use ?
    why do this remove& add sequence anyways?

    Thanks.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.