'block data flow from a TCP socket
I'm using libsoccr, which allows to checkpoint/restore TCP connection. Here is how I'm trying to use it :
/* some code to initialize and connect the socket */
#define max 10000000
struct libsoccr_sk *so;
struct libsoccr_sk_data data;
int sockfd, dsize, size;
char *buff = (char *)malloc(MAX * sizeof(char));
/* some code to fill the buffer */
write(sockfd, buff, MAX);
so = libsoccr_pause(sockfd);
dsize = libsoccr_save(so, &data, sizeof(data));
/* some code */
The function libsoccr_save(so, &data, sizeof(data)) returns me -6.
I re read libsoccr's documentation, and found out "any data flow for this socket must be blocked by the caller before this call" talking about libsoccr_pause(sockfd). I looked into the source code and found out that the queue length is got with ioctl(sockfd, SIOCOUTQ, &size) and later, the content of the queue itself is got with ret = recv(sockfd, buf, size+1, MSG_PEEK | MSG_DONTWAIT). Using gdb, it appears that I always get ret = 0 even if the queue is not empty, surely because I don't block the data flow of the socket, but I have no clue on how to do it.
So the question is, how can I block the data flow of a socket ?
Solution 1:[1]
A good way to block the data flow of a socket is to use "plug qdisc". All the documentation can be found here : https://www.infradead.org/~tgr/libnl/doc/api/group__qdisc__plug.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MatMo |
