I have the following function in C :
struct mptcp_subflow_data inf;
memset(&inf, 0, sizeof(inf));
inf.size_subflow_data = sizeof(struct mptcp_subflow_data);
inf.size_user = 0;
socklen_t optlen = sizeof(inf);
if (getsockopt(fd, 284, 2, &inf, &optlen) < 0){
if (errno != EOPNOTSUPP){
return -1;
}
return -2;
}
return inf.num_subflows;
I’m trying to achieve the same thing in Python, however I realized that socketmodule uses another function to initialize the buffer. Is there any way to achieve this in Python3 ? The goal is to initialise the buffer passed on to the C extension ?
returned = sock.getsockopt(284, 2, 16)
print(struct.unpack("=IIII", returned))
The above solution doesn’t work because we need to initialize the buffer passed on
Thank you very much in advance.