NO

Author Topic: HttpApi: HttpReceiveHttpRequest freezes my program  (Read 9613 times)

Fred_Pyo

  • Guest
HttpApi: HttpReceiveHttpRequest freezes my program
« on: February 04, 2007, 03:26:58 AM »
Hello, I am attempting to write a little server "application" to give a new project of mine a web interface. So after reading the Microsoft SDK I found out about HttpAPI, so I gave it a try.

Unfortunately, even though I took as many precautions as possible, and even followed closely the example code in the SDK. The program doesn't work (see attached server.c file).

So I added breakpoints to my app and debugged it. For some strange reason, once I call HttpReceiveHttpRequest (...) in line 121, the program enters what appears to be an infinite loop, and doesn't continue executing the rest of the lines bellow the call to that function.

One possibility is that I am using HttpApi.lib from the SDK, because I didn't find in under Pelle's library files, which may be causing some odd behavior.

In any case, if anybody can help me, I will appreciate it very very much.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
HttpApi: HttpReceiveHttpRequest freezes my program
« Reply #1 on: February 05, 2007, 11:03:53 AM »
That's absolutely normal, because the function "HttpReceiveHttpRequest" performs a so called "blocking call" when used in synchronous mode. In windows sockets could be used in blocking or unblocking calls (the last are called asyncrhronous call). To avoid blocking you must set the parameter For asynchronous calls, pOverlapped, to point to an OVERLAPPED structure.
But do you really need it ?????  :mrgreen:
Your code blocks because no request is detected. Try checking net stuff (IP addresses, netmask and so on).
Anyway take a look also here http://msdn2.microsoft.com/en-us/library/aa364495.aspx
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
HttpApi: HttpReceiveHttpRequest freezes my program
« Reply #2 on: February 05, 2007, 04:08:30 PM »
I got it! 8)
You mixed printf and wprintf in your code, and this creates problems with PellesC I/O: once you emitted the first printf all the other wprintf prints nothing!  :cry:
Change everything to printf and you'll get the answer from interrogations.
Here works.  :mrgreen:
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Fred_Pyo

  • Guest
HttpApi: HttpReceiveHttpRequest freezes my program
« Reply #3 on: February 05, 2007, 04:18:30 PM »
Yay! Thanks, now at least the console shows that requests are being sent! But it doesn't seem to be sending correct information to the browser. Back to work...

Thank you very much frankie!