Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

winsock and connect to proxy

Posted on 2001-06-11
5
Medium Priority
?
262 Views
Last Modified: 2008-02-26
Please help me.

I can't figure out why the connect does not response.

Sample code. Not sure if you need more.

  printf("send header\n");
  //GET / \r\nHost:abc.go.com\r\n
  //sprintf(head,"GET %s HTTP/1.0\n\n",_fil);
  sprintf(head,"GET http://abc.go.com HTTP/1.0\r\n");
  if (send(soc,head,strlen(head),0) != (int) strlen(head))
  {
   printf("error sending header!\n");
   exit(1);
  }
 
     //fd_set fds;

    FD_ZERO(&fds);
   FD_SET(soc,&fds);

  select (soc + 1, &fds, NULL, NULL, NULL);//This one i lazy.
  if (FD_ISSET(soc,&fds))
  {
       
       char cc[100];
          if(recv(soc,cc,sizeof(cc),0)>0)
           abc(cc);
  }

Regards
Andla
0
Comment
Question by:andla
[X]
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
  • 2
  • 2
5 Comments
 
LVL 5

Expert Comment

by:robpitt
ID: 6180424
You HTTP headers are unterminated, the server is waiting for the rest of the data. HTTP headers must end in a blank line, add another \r\n to the end of your headers to achieve this.


Also consider using HTTP1.1 and specifying a HOST header - see the RFC2616 for more info.
0
 
LVL 1

Author Comment

by:andla
ID: 6181536
Thanks!

I have tried that if you mean
"GET http://abc.go.com HTTP/1.0\r\n\r\n");

Yesterday just before i went to sleep i searched for an answer in the newsgroups. I saw that i missed a "/" character after the http://abc.go.com and. After that it worked, hurray. I'm pretty new to this and i value your experience with winsock programming. I will remember the two '\r\n\r\n'. What i think (not sure)is that if i want to cover a broader functionality of the GET string i will also have to try one \r\n or \n\n. Is it general that i must use a '/' after the URL ?

/Andla
0
 
LVL 5

Accepted Solution

by:
robpitt earned 200 total points
ID: 6194354
Ooops, yes I should have spotted the missing "/" from the end.

I would also encourage you to use HTTP1.1 as many websites require it these days.
E.g.
  "GET www.blah.com/ HTTP/1.1\r\n"
  "Host: www.blah.com\r\n"
  "\r\n"

0
 
LVL 11

Expert Comment

by:griessh
ID: 6814562
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and PAQ at zero points since you found your own solution.

The link to the Community Support area is: http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt

Please do not accept this comment as an answer!
======
Werner
0
 
LVL 1

Author Comment

by:andla
ID: 6815460
I'm very sorry that i have forgotten this :-( . Shame on me.
Very sorry.
Andla
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

688 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