setsockopt
函数第二个参数level是被设置的选项的级别,如果想要在套接字级别上设置选项,就必须把level设置为 SOL_SOCKET。
int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
memset
函数void *memset(void *s, int ch, size_t n);
作用
En
Copies the value static_cast<unsigned char>
(ch) into each of the first count characters of the object pointed to by dest. If the object is a potentially-overlapping subobject or is not TriviallyCopyable (e.g., scalar, C-compatible struct, or an array of trivially copyable type), the behavior is undefined. If count is greater than the size of the object pointed to by dest, the behavior is undefined.
Ch
将ch的值复制到dest指向的对象的前count个字符中。如果对象是潜在重叠的子对象或不是TriviallyCopyable(例如,标量,C兼容的结构或平凡可复制的类型的数组),则行为是未定义的。如果count大于dest指向的对象的大小,则行为是未定义的。
复制ch的值到 s 指向的对象的前 n 个字符中。
void *memset(void *s, int ch, size_t n);
返回一个指向内存块 s 的指针。
snprintf
函数En Writes formatted data from variable argument list to sized buffer. Ch 将格式化的数据从变量参数列表写入大小缓冲区。
int snprintf( char *buffer, size_t buf_size, const char *format, ... );//可变参数