简体   繁体   中英

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 :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM