c++ - async tcp socket and progress when sending data -


I use http based file uploads in my C ++ code (which runs on Linux / Android). I use async tcp socket to write file data. My point is that my progress bar shows what has been sent in the socket, what exactly is sent on the wire. The problem is clear with slow links, where more than 100% more seconds are sent and send the full message.

I do not modify SO_SNDBUF, in my case, by 35KB (query) hokkapet) how can I correctly correct the progress of the current transfer status to reflect progress? Is there a way to query the size of the data present in the buffer? Is there a way to get TCP notification about the transfer progress (as confirmed by remote socket)?

You are not able to know the current size of this buffer, because it is in the kernel ground And there is no known / documented ioctl to tell its size even you know it, it will not be portable, thus I do not think it is a good way to solve this problem.

You either:

  • To estimate the data rate during the entire transition, in the end, the time remaining for this buffer SO_NDBUF

  • Use third party library, which will include the last count!

    Edit: After some research in the book, TCP / IP Architecture, Design & amp; Implementation in Linux , I have seen the NETLINK_TCPDIAG option for TCP socket monitoring. I Netlink chairs are an IPC method between kernel and user land. For the NETLINK_TCPDIAG option, unfortunately, there is no description ... I just know that you have to create a socket like this: int fd = socket (AF_NETLINK, SOCK_RAW, NETLINK_TCPDIAG) < / Code> and Root privileges are required to create raw sockets.

    After that, your only friend looks at linux / net / ipv4 / tcp_diag.c () ... but nothing about this type of protocol is Google. .. Good luck!

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -