http server

This is a discussion on http server within the C Programming forums, part of the General Programming Boards category; I am running a server program on my local machine using port 8080 which prints whatever string is found from ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    134

    http server

    I am running a server program on my local machine using port 8080 which prints whatever string is found from the client.

    If I use a browser and enter the following address on address bar:
    Code:
    http://127.0.0.1:8080/a.txt
    Nothing happens on server end and on the browser it says:

    Code:
    Unable to connect, browser can't establish a connection to the server at 127.0.0.1:8080.
    If I use 6000 as port number instead of 8080 on server and on browser, browser says:

    Code:
    This address is restricted
    I want to connect to the erver using browser and print on the server whatever is sent by the browser!!!

  2. #2
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    I'll assume that you wrote the server program.

    Are you sure that it's a problem with the browser and not with the server software?

    Have you tried using telnet (or your OS equivalent) to telnet to the server and see if it prints what you type?

    Frankly, I have no idea what you want from us. Seeing as this thread isn't in tech support, it seems to be a C problem. Seeing as you haven't actually mentioned C, it seems you think it is a browser problem.

    Post some source.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    134
    Yes I have written the server program using C, and also a client program.

    The client program connects correctly, and whatever is entered on client is printed on server.

    But what I thought, if I run a browser in the way I mentioned previously, it will connect to the server accordingly and print on server whatever browser sends to server.

  4. #4
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    TCPView might give you an idea of what is happening (assuming you are on Windows).

  5. #5
    Registered User
    Join Date
    May 2008
    Posts
    134
    No I am using Linux, and I don't think that what I am trying to do is platform dependent.
    just I want to interact browser on client with the C-server on server!!!

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Is your program really called a.txt?

  7. #7
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    Quote Originally Posted by tabstop
    Is your program really called a.txt?
    The browser isn't invoking his application. He is simply trying to see the data that a browser sends to a web server to request a page (such as a.txt). At least, this is what I gather from the thread so far.

    @OP, I achieved this some while ago when I was trying to get my PSP to control the audio on my computer (failed project). From what I remember, you are using your browser correctly and so there must be some fault with your server program. Try some basic debugging with print statements to find out what is happening. Also try to use a third party telnet client (something that you did NOT write) to access the server and see what happens.

    At the current time, you know a lot more about your server than we do. I'm not sure how you expect us to help you more than you can help yourself.

  8. #8
    Registered User
    Join Date
    May 2008
    Posts
    134
    I think u understood properly, but I have not used telnet, I have used my client program, and is connected to server,

    the server profram is simple, it just accept any client(using socket programming) on that port and prints whatever it gets from the client on the accepted socket!

  9. #9
    Registered User
    Join Date
    Jan 2009
    Location
    Australia
    Posts
    375
    I realise that you have not yet used a telnet client to access it, but I'm not sure why not. It is possible that you have made the same error in both server and client program and so testing it with a simple third party client will eliminate this possibility (or confirm it).

    If you are unwilling to listen to suggestions, don't ask for help.

    Like I said, I cannot see anything wrong with what you are trying to do (haven't done it in a while though and I'm no expert on it) so it's more likely that there is a bug in your server application.

  10. #10
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Code:
    telnet localhost 8080<enter>
    GET /a.txt HTTP/1.1<enter>
    Host: localhost<enter>
    <enter>

  11. #11
    Registered User
    Join Date
    May 2008
    Posts
    134
    This msg is comming when I am trying using telnet: as
    telnet 10.117.124.85 8080
    Trying 10.117.124.85...
    telnet: connect to address 10.117.124.85: Connection refused
    this is LAN IP, I have used all the three ips.. local, LAN, Internet, but no use.

  12. #12
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,650
    Your firewall is either blocking you, or your server is not running and accepting connections on port 8080.

  13. #13
    Registered User
    Join Date
    May 2008
    Posts
    134
    How to chek weather firewall is blocking? OR how can I top it?
    I don't think this is the case as when I start httpd sevice, it perfectly works fine, I mean I can see my homepage working.

    The server is also running fine on 8080 port as my client is easilyable to connect to the server, but the problem is with the server.

    The server architecture/code is almost same as: The World of select()
    The client is simple socket client program.

  14. #14
    Registered User
    Join Date
    May 2008
    Posts
    134
    I used getaddrinfo() in the server program, now server prints some msgs when I am using browser.

    but the client doesn't, moreover the server gives Segmentation fault core dump.

  15. #15
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,705
    Guessing games are sometimes fun...but rarely productive. Post your code.
    Code:
    #include <cmath>
    #include <complex>
    bool flip(bool value)
    {
           return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0)*(1 << (value + 2)))
        ).real() < 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. INT 15 to return memory size
    By pole1080 in forum C Programming
    Replies: 49
    Last Post: 06-23-2010, 09:28 AM
  2. Tokenize HTTP server response
    By maganese187 in forum Networking/Device Communication
    Replies: 2
    Last Post: 03-09-2009, 07:17 AM
  3. Help with Parsing HTTP response from server
    By NuNn in forum C Programming
    Replies: 4
    Last Post: 02-19-2009, 02:02 PM
  4. HTTP Server?
    By Nebbuchadnezzar in forum Tech Board
    Replies: 9
    Last Post: 07-30-2005, 03:46 PM
  5. socket question
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 07-19-2002, 01:54 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21