Note that there are some explanatory texts on larger screens.

plurals
  1. POserver socket receives 2 http requests when I send from chrome and receives one when I send from firefox
    primarykey
    data
    text
    <p>I wrote a simple server using socket API in C under linux which listens at port 80 on localhost. Now when I send a request from the browser google chrome to the program it receives 2 requests while it receives only one when I send from firefox.</p> <p><em>The URL I typed in the browser was: <a href="http://localhost/xyz.html">http://localhost/xyz.html</a></em></p> <p>OUTPUT WHEN I TYPE URL IN CHROME</p> <pre><code>root@anirudh-Aspire-5920:/home/anirudh/workspace/DCMTOL# ./DCMTOL_RUN Inside HTTP server Handler Inside HTTP request Handler **Detected request: clientsocket_fd = 6 clientportnumber = 38027** GET /xyz.html HTTP/1.1 Host: localhost Connection: keep-alive Cache-Control: max-age=0 Accept:application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.224 Safari/534.10 Accept-Encoding: gzip,deflate,sdch Accept-Language: en-US,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Inside HTTP request Handler **Detected request: clientsocket_fd = 7 clientportnumber = 38029** ^C root@anirudh-Aspire-5920:/home/anirudh/workspace/DCMTOL# </code></pre> <p>the second request does not send any data so my code waits at the read call and so I have to terminate it '^C'.</p> <p>OUTPUT WHEN I TYPE URL IN FIREFOX</p> <pre><code>root@anirudh-Aspire-5920:/home/anirudh/workspace/DCMTOL# ./DCMTOL_RUN Inside HTTP server Handler Inside HTTP request Handler **Detected request: clientsocket_fd = 6 clientportnumber = 45567** GET /xyz.html HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101206 Ubuntu/10.10 (maverick) Firefox/3.6.13 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive ^C root@anirudh-Aspire-5920:/home/anirudh/workspace/DCMTOL# </code></pre> <p><strong>Question: How can chrome browser send 2 requests (one being empty) when I typed the URL only once. As you can see above I detected 2 requests. I tried to do netstat in the case of sending URL from chrome and I found that both of the request were sent by the browser only. and as u can see above when I send the URL from firefox only 1 request is received.</strong></p> <p><strong>Here is the output of net stat when I send request from chrome</strong></p> <pre><code>Active Internet connections (w/o servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 117.195.110.186:48701 74.125.77.102:80 TIME_WAIT - tcp 0 0 117.195.110.186:48700 74.125.77.102:80 ESTABLISHED 5699/google-chrome tcp 0 0 117.195.110.186:55815 209.85.175.138:80 ESTABLISHED 5699/google-chrome tcp 0 0 127.0.0.1:80 127.0.0.1:38029 ESTABLISHED - tcp 0 0 127.0.0.1:38029 127.0.0.1:80 ESTABLISHED 5699/google-chrome tcp 0 0 127.0.0.1:38027 127.0.0.1:80 ESTABLISHED 5699/google-chrome tcp 0 0 127.0.0.1:80 127.0.0.1:38027 ESTABLISHED - tcp 0 0 117.195.110.186:35402 74.125.153.125:5222 ESTABLISHED 4430/pidgin </code></pre> <p>thanks in advance :)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload