Results 1 to 5 of 5
Hi
I want to create an application to check if a site is active or inactive (homework for networking ). For that I need to connect to the ip at ...
- 01-03-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
HTTP status in C
Hi
I want to create an application to check if a site is active or inactive (homework for networking ). For that I need to connect to the ip at which the site resides and get the status. For that I create a socket with the IP and the port 80 and try to read an answer.
First of all I want to ask if this is the correct course of actions.
Second, I cannot connect with my socket to the designated IP and port 80 - it gives me: Connection refused. How can I connect to the server on which the site resides correctly.
What message I should send to the server to get as response the status of the site or better an error code (404, 500, 200) from which I can see the status of the site.
PS. I can use only the standard libraries on C under LINUX (it is a homework and I cannot use libraries made by someone else)
Thank you in advance. Any help will be much appreciated.
- 01-03-2009 #2
If you mean by "site" a running http server, yes.
But keep in mind there is a difference between source and destination port.
Every HTTP request returns some status code in the header of the http message if the http server is running and can be reached.
Read RFC 2616 to learn more about this.
When I want to get some idea of the traffic, I open netcat or telnet and connect to the server. This way, I can play around and it prints out any answer on my screen. If this works correctly, I implement it in C.Debian GNU/Linux -- You know you want it.
- 01-03-2009 #3Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
Thank you GNU-Fan for pointing the helpful info.
I need some samples of C code because I'm more of a PHP programmer and I don't know all the functions needed to do this others from the few I learned at the university.
- 01-03-2009 #4
Oh, there is lots of it.
For example, HappyHTTP - a simple HTTP libraryDebian GNU/Linux -- You know you want it.
- 01-04-2009 #5Just Joined!
- Join Date
- Jan 2009
- Posts
- 3
Thank you again GNU-Fan. This library is the perfect example for me.
Really appreciate.


Reply With Quote
