Thread: My Client Socket Program not receiving response

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by Salem View Post
    Well you need to look closely at what's in packet 139, because the response in packet 141 is "bad request".
    Also, you only need worry about protocol=HTML messages. The TCP chatter probably isn't all that useful.

    > send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    Like recv(), there is no guarantee that the whole message is sent in a single call.

    At least start with
    Code:
    int s = send(http_client_socket, http_request.c_str(), http_request.length(), 0);
    if ( s != http_request.length() ) { std::cerr << "Oops on send\n"; }
    Are you able to fetch testcat_al.html using your browser?
    If you are, comparing the browser's version of "GET" with your version will tell you a lot.
    The http GET request is definitely different when made from the browser. In comparison:

    My Client Socket Program not receiving response-screen-shot-2022-09-26-10-43-47-am-jpg

    I noticed that IPv4 addresses are different from my browser, the IPv4 address of the test server is being resolved to 100.21.215.181 whereas in my program, it is being resolved to 34.218.221.118 I have to assume that the website's has a cluster of IP addresses and is dynamic.

    When the same site is fetched from the browser, Wireshark does show a HOST field which doesn't happen with my client socket program. That tells me I must be doing a lot of things wrong.

  2. #2
    Registered User
    Join Date
    Sep 2022
    Posts
    11
    Quote Originally Posted by badCProgrammeur View Post
    The http GET request is definitely different when made from the browser. In comparison:

    My Client Socket Program not receiving response-screen-shot-2022-09-26-10-43-47-am-jpg

    I noticed that IPv4 addresses are different from my browser, the IPv4 address of the test server is being resolved to 100.21.215.181 whereas in my program, it is being resolved to 34.218.221.118 I have to assume that the website's has a cluster of IP addresses and is dynamic.

    When the same site is fetched from the browser, Wireshark does show a HOST field which doesn't happen with my client socket program. That tells me I must be doing a lot of things wrong.
    @Salem, I have changed the code for send, and I'm not sure why still my code for the GET request is generating a different result from the browser. One thing I did notice though besides the aforementioned was that \r\n was missing from the browser request. However, from what I know, "HTTP/1.1\r\n\r\n" is needed in the GET request.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client Socket Program to connect to SSH Server
    By emmaclark in forum C Programming
    Replies: 4
    Last Post: 12-27-2016, 03:09 AM
  2. C / Unix: client program with listeninig socket
    By YocR in forum Networking/Device Communication
    Replies: 4
    Last Post: 08-16-2013, 01:27 AM
  3. not receiving messages in server/client program
    By ueg1990 in forum C Programming
    Replies: 5
    Last Post: 07-08-2012, 07:57 PM
  4. writing a client program - socket programming Linux
    By rehman12390 in forum Linux Programming
    Replies: 4
    Last Post: 01-08-2012, 04:18 PM
  5. Replies: 10
    Last Post: 01-27-2010, 01:20 AM

Tags for this Thread