getsockopt(), setsockopt() not working. socket buffer size,..
Posted: Sat Jan 07, 2017 2:01 pm
Hi,
In order to get the socket buffer size, My codes call the function getsockopt() .
However, the return value is always -1, and the err msg is "Protocol not available".
the codes I used,
ESP-IDF version 1;
In order to change the socket buffer size, the function setsockopt() also returns an error.
Questions.
1. How can I get the socket buffer size ?
2. How can I set the socket buffer size ?
3. What is the default socket size ?
In order to get the socket buffer size, My codes call the function getsockopt() .
However, the return value is always -1, and the err msg is "Protocol not available".
the codes I used,
ESP-IDF version 1;
Code: Select all
void Init_Client_mySocket(void)
{
struct sockaddr_in serverAddress;
memset(&serverAddress,0,sizeof(serverAddress));
// Create a socket client
int sock = socket(AF_INET, SOCK_STREAM,0);// IPPROTO_TCP);
if (sock < 0) {
printf("socket: %d %s", sock, strerror(errno));
goto END;
}
printf("socket: %d Created OK\n", sock);
/// socket option
int bsize=0;
socklen_t optlen;
optlen = sizeof(bsize);
int retv_gso = getsockopt(sock,SOL_SOCKET,SO_RCVBUF,&bsize,&optlen);
printf("getsockopt retv = %d. err msg=%s\n",retv_gso,strerror(errno));
printf("rcv Buf Size = %d\n", bsize);//
...
Questions.
1. How can I get the socket buffer size ?
2. How can I set the socket buffer size ?
3. What is the default socket size ?