Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sockets 套接字编程:这里出了什么问题?_Sockets_Tcp - Fatal编程技术网

Sockets 套接字编程:这里出了什么问题?

Sockets 套接字编程:这里出了什么问题?,sockets,tcp,Sockets,Tcp,代码 编译(gcc…)警告 但是“inet_ntoa()”确实应该返回“char*”,对吗?默认情况下,在没有活动原型的情况下使用的函数会返回int。ISO C标准(至少在C90中)规定了这种行为 您需要包含声明该函数的头文件,以便编译器具有正确的原型。好,缺少#include,但是默认值是什么?它在哪里? struct sockaddr_in ser; ... #line 68 fprintf(stderr, "Can't find host %s\n", inet_ntoa(ser.sin_

代码

编译(gcc…)警告


但是“inet_ntoa()”确实应该返回“char*”,对吗?

默认情况下,在没有活动原型的情况下使用的函数会返回
int
。ISO C标准(至少在C90中)规定了这种行为

您需要包含声明该函数的头文件,以便编译器具有正确的原型。

好,缺少#include,但是默认值是什么?它在哪里?
struct sockaddr_in ser;
...
#line 68
fprintf(stderr, "Can't find host %s\n", inet_ntoa(ser.sin_addr));
68: warning: format '%s' expects type 'char *', but argument 3 has type 'int'