Winsock and HTTP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Christian Drescher

    Winsock and HTTP

    I try to build something like a web interface for one of my tools. I have
    got a problem:

    char sendBuf[] = "HTTP/1.1 200 OK\nContent-Type:
    text/html\n\n<HTML>\ n<BODY>\nHallo\ n</BODY>\n</HTML>\n";

    I used winsock2 to send - no error in sending, but the browser do not like
    to deal with the information in sendBuf[]. Is there something wrong in my
    understanding of the HTTProtocoll?


  • Unforgiven

    #2
    Re: Winsock and HTTP

    "Christian Drescher" <christian.dr@g mx.net> wrote in message
    news:chioiu$vs6 $1@cephyr.cid.n et...[color=blue]
    >I try to build something like a web interface for one of my tools. I have
    >got a problem:
    >
    > char sendBuf[] = "HTTP/1.1 200 OK\nContent-Type:
    > text/html\n\n<HTML>\ n<BODY>\nHallo\ n</BODY>\n</HTML>\n";
    >
    > I used winsock2 to send - no error in sending, but the browser do not like
    > to deal with the information in sendBuf[]. Is there something wrong in my
    > understanding of the HTTProtocoll?[/color]

    1. Both WinSock and HTTP are off topic in this group.
    2. HTTP requires CRLF (\r\n) pairs as line endings, so that's probably your
    problem.
    3. More info: http://www.ietf.org/rfc/rfc2616.txt?number=2616

    --
    Unforgiven

    Comment

    • Christian Drescher

      #3
      Re: Winsock and HTTP

      I edited answere in definition of HTTP

      --code--

      strcpy(sendbuf, "HTTP/1.0 200 OK\r\n" );
      strcat(sendbuf, "Server: Custom server\r\n");
      strcat(sendbuf, "Date: Tuesday, 07-Sep-04 14:47:04 GMT\r\n");
      strcat(sendbuf, "Last-modified: Thursday, 07-Sep-04 10:44:53 GMT\r\n");
      strcat(sendbuf, "Content-length: 6372\r\n");
      strcat(sendbuf, "Content-type: text/html\r\n");
      strcat(sendbuf, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2
      Final//EN\">\r\n");
      strcat(sendbuf, "<html>Hell o</html>");

      --/code--

      The problem is that when I try to connect to the server though Internet
      Explorer, I do't receive the answer from the server. Why?

      For more details, I do the next thing:
      1. The server runs on my computer, and waits connections
      2. In Internet Explorer, I enter localhost-address 127.0.01
      3. The server says that there is a client who is connected.
      4. The server receives the request from the client.
      5. The server sends an answer.
      6. ERR: Internet Explorer prints "The page cannot be displayed".

      I suppose that it must be an error in formating of my answer...


      Comment

      • red floyd

        #4
        Re: Winsock and HTTP

        Christian Drescher wrote:[color=blue]
        > [redacted]
        >[/color]
        Once more: WinSock and HTTP are off topic in this group, as is IE. Try
        a windows programming group.

        Comment

        • Christian Drescher

          #5
          Re: Winsock and HTTP

          > Try a windows programming group.

          such as?


          Comment

          • red floyd

            #6
            Re: Winsock and HTTP

            Christian Drescher wrote:
            [color=blue][color=green]
            >>Try a windows programming group.[/color]
            >
            >
            > such as?
            >
            >[/color]

            anything with the name "microsoft" or "windows" in it?

            for example: microsoft.publi c.vstudio.devel opment
            or even comp.windows.ms .programmer


            Comment

            • John Harrison

              #7
              Re: Winsock and HTTP


              "Christian Drescher" <christian.dr@g mx.net> wrote in message
              news:chkk5i$m22 $1@cephyr.cid.n et...[color=blue][color=green]
              > > Try a windows programming group.[/color]
              >
              > such as?
              >[/color]

              news:comp.os.ms-windows.program mer.win32

              john


              Comment

              Working...