简体   繁体   English

如何发送C ++ Winsock获取请求?

[英]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 我正在尝试编写一个bittorrent客户端,我需要弄清楚如何使用一些特定参数向跟踪器发送HTTP GET请求,这些参数可以在以下位置找到: 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? 我想我只是了解如何打开套接字,但是我将如何在Windows上的C ++中发送GET请求?

Any help would be greatly appreciated :) 任何帮助将不胜感激 :)

When your TCP socket is open, you need to issue a HTTP GET request. 打开TCP套接字后,您需要发出HTTP GET请求。 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 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后加上参数:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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