Results 1 to 3 of 3

Thread: How to ping a server ?

  1. #1
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default How to ping a server ?

    Hi,

    I've a simple application that alerts the user when he got new mails on our Intranet messagery server.

    To know if there are new mails, I use a QTcpSocket connected to our Intranet messagery server on port 143, and I request for new mails with IMAP protocol. When I can't get the answer, I show an error message saying that the connection as failed, and that the user should check is connection to the network.

    The matter is that the user could be well connected but our messagery server would be down.
    So, before showing the error, I should test :
    - if I can ping our messagery server
    - if I can ping another Intranet server

    Pinging the messagery server is simple, with IMAP : I've just to tell him that I want a connection.
    But I don't know how to ping another Intranet server, nor on wich port. I would like to do a classical 'ping servername'.

    Is it possible, without calling external libraries ?

    Thanks for your help !

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to ping a server ?

    "ping" uses the ICMP protocol and not TCP and there are no "ports" in ICMP. The simplest way would be to call the system tool ping, because creating ICMP packets requires superuser priviledges, so there is a good chance you won't be able to forge it in a user application. Also beware of the fact that the modern policy (mainly in Windows) says that pings should be blocked, so you might not get any result back. I would suggest trying to connect to a different service (like http) instead.

  3. #3
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to ping a server ?

    Thanks for the tip .

    Here is my situation :
    - server A : provides acces to external services (Web), through a proxy
    - server B : provides some internal services, like FTP, HTTP, ...
    - server C : provides some internal servicies, like IMAP messagery, DNS, ...

    So, what I will test is :
    - if the IMAP service is running on server C, with an IMAP request
    - if the DNS service is running on server C, with a QHttp request targetting an intranet web site (HTTP service provided by server B, but DNS resolved on server C)
    - if the B server is running, testing an intranet HTTP request with the server IP (in order not to use the DNS service on server C)
    - if the server A is running, testing an external QHTTP request

    That's a good idea !
    I was on my "ping" solution snce this morning, for nothing

Similar Threads

  1. cannot connect to X server
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 18th April 2007, 15:22
  2. How a server can write "Hello" to a browser ?
    By probine in forum Qt Programming
    Replies: 2
    Last Post: 1st December 2006, 15:43
  3. Replies: 1
    Last Post: 4th October 2006, 17:05
  4. Sql Server cannot retrieve data from select
    By Atomino in forum Qt Programming
    Replies: 10
    Last Post: 7th September 2006, 17:37
  5. synching client readings to server output
    By OnionRingOfDoom in forum Qt Programming
    Replies: 14
    Last Post: 28th January 2006, 19:15

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.