brnby
brnby

Reputation: 1523

How to send C++ winsock Get Request?

I'm trying to write a bittorrent client and I need to work out how to send a HTTP GET request to the tracker with some specific parameters which can be found here: http://jonas.nitro.dk/bittorrent/bittorrent-rfc.html#anchor18

I think I just about understand how to open a socket but how would I send a GET request in C++ on windows?

Any help would be greatly appreciated :)

Upvotes: 0

Views: 6480

Answers (1)

BxlSofty
BxlSofty

Reputation: 501

When your TCP socket is open, you need to issue a HTTP GET request. This is actually very simple: you just need to send through the socket a series of text lines, as described for example here:

http://www.jmarshall.com/easy/http/#sample

You ends your request with an empty line.

Then you wait for the server to reply, and you cross your fingers...

In your case, all the parameters will be on the GET line with parameters after the URL:

GET url?param1=value1&param2=value2&param3=value3

Upvotes: 1

Related Questions