-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_buf.c
More file actions
executable file
·41 lines (33 loc) · 886 Bytes
/
get_buf.c
File metadata and controls
executable file
·41 lines (33 loc) · 886 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Created by Administrator on 2019/1/2.
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/socket.h>
void error_handling(char *message);
int main(int argc, char *argv[]) {
int sock;
socklen_t len;
int snd_buf, rcv_buf, stat;
len= sizeof(snd_buf);
sock=socket(PF_INET, SOCK_STREAM, 0);
stat=getsockopt(sock, SOL_SOCKET, SO_SNDBUF, (void*)&snd_buf, &len);
if (stat) {
error_handling("getsockopt() error!");
}
len= sizeof(rcv_buf);
stat=getsockopt(sock, SOL_SOCKET, SO_RCVBUF, (void*)&rcv_buf, &len);
if (stat) {
error_handling("getsockopt() error!");
}
printf("Input buffer size: %d\n", rcv_buf);
printf("Output buffer size: %d\n", snd_buf);
close(sock);
return 0;
}
void error_handling(char *message) {
fputs(message, stderr);
fputc('\n', stderr);
exit(1);
}