0

I am trying to create a small C socket server. The server sends out the HTTP/HTML responses fine enough. But the clients would be sending it HTML requests and clients can be different devices - mobile apps, browsers etc. I need to log the requests about which type of devices are requesting what.

I happen to know that browser usually sends cookies and its user-agent info to the server as well and I want my server to be able to record the cookie and user-agent strings as well.

So how do I enable the reading of HTTP headers in my C/C++ server?

roalz
  • 2,699
  • 3
  • 25
  • 42
Vaibhav Kaushal
  • 340
  • 1
  • 6
  • 16
  • Look this answer http://stackoverflow.com/questions/22077802/simple-c-example-of-doing-an-http-post-and-consuming-the-response – Jayesh Bhoi Sep 19 '14 at 09:42
  • Why not use php instead? – Abhi Sep 19 '14 at 09:43
  • @Abhi The server has to be in C for performance reasons and can get lot of requests. The requirement is pretty simply for now. Also, the server might have to be embedded into some kind of device later (not sure about that). – Vaibhav Kaushal Sep 19 '14 at 10:06
  • Maybe start somewhere like here: http://code.tutsplus.com/tutorials/http-headers-for-dummies--net-8039 , and then attempt to code what you need? (As I understand you already have the socket part working) – Jubatian Sep 19 '14 at 16:17
  • SO it still does not tell me how to read the entire GET request. – Vaibhav Kaushal Sep 19 '14 at 22:38

1 Answers1

0

What I was trying to do was essentially read from the socket. So using recv, the problem was solved. I was thinking complex while the solution was simple.

Vaibhav Kaushal
  • 340
  • 1
  • 6
  • 16