HTTP GET Method Speed ​​in C ++

I use some libraries in a C ++ program to connect and select other websites. I mainly used Chillkat and Curl. However, I recently started programming my own HTTP receiver using MSDN and the Winsocket2 library.

I programmed my software to open a socket of type SOCKET_STREAM for Ipv4, and then I establish a connection to the desired website and send a GET request with the headers "Host:" and "Connection: close" to the server. Everything seems to be working fine, but the performance is not what I expected. The included Chillkat library is still preforms better than mine. Despite the fact that I optimized mine as much as I can.

I notice that when I submit a request, some servers take longer to respond. And as soon as they do this, they send everything right away. So how can I make a header request that triggers a quick response? Speed ​​is very important for my program.

+3
source share
2 answers

If you see a performance difference on a modern machine with low volumes, the most likely problem is that you forgot to disable the Nagle algorithm. Use setsockopt () to set TCP_NODELAY to 1. HTTP is not Telnet.

- , , , . .

. SO_SNDBUF SO_RCVBUF. , , , .

+1

, HTTP - , . , , , , Chillkat Curl, . , ( Nagle) . ( ), . , "".

, , , , , , .

0
source

Source: https://habr.com/ru/post/1789102/


All Articles