sending "HTTP/1.0 200 OK \r\n" does not work in the browser(ie5.0)!

Posted on 2003-03-24
Medium Priority
Last Modified: 2013-11-20
   I am writing a proxy server with C using vc++ 6.0
   I am using WIN32 API and NOT USING MFC. My problem is
   sending the basic HTTP headers just does not work in
   the browser! I have included the code. Pleash HELP!

#include "main.h"    
void main()
     WSAData wData;
     SOCKET serverSocket;    
     SOCKADDR_IN serverAddr;

     WSAStartup(MAKEWORD(2, 0), &wData);

     serverSocket=socket(AF_INET, SOCK_STREAM, 0);

     bind(serverSocket, (struct sockaddr *)&serverAddr, sizeof

     listen(serverSocket, 10);

          SOCKADDR_IN clientAddr;
          int clientAddrLen=sizeof(clientAddr);

          SOCKET client=accept(serverSocket, (struct sockaddr *)      
                                     &clientAddr, &clientAddrLen);          
          char * resp="HTTP/1.0 200 OK\r\n"
                   "Content-type: text/html\r\n\r\n"

          send(client, resp, strlen(resp), 0);

          shutdown(client, 0x2);          


Question by:kashokshenoy
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

cmaryus earned 1740 total points
ID: 8201109
you MUST call receive first.
when connecting to a server the browser send a request, then it reads for the answer from the server.
so after accept, do :
char szRecvbuf[2049];
recv(client, szRecvbuf, 2048, 0);
then you can send the buffer

Author Comment

ID: 8211809
Thanks for the timely help.

You saved my scalp!!!

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question