我的程序用这个函数打开一个套接字:
sockfd = socket(AF_INET,SOCK_RAW,IPPROTO_ICMP)
完成发送数据后,套接字关闭:
关闭(的sockfd);
但问题是当程序运行不顺畅并且阻塞时.因此插座不会关闭.
如何检查在Linux OS下打开的所有套接字?
在我的程序中,我必须创建一个隐藏文件,以避免删除或修改文件
PATH=/etc/
NAME = file
Run Code Online (Sandbox Code Playgroud)
所以我问c中是否有功能允许这样做?
谢谢
当我运行我的程序时,我收到系统崩溃"Segmentation fault"消息.
我想知道是否有办法确切地知道导致系统崩溃的指令(代码行)分段错误消息"
代码===>
#include "GeoIP.h"
int main()
{
FILE *f;
char ipAddress[30];
char expectedCountry[3];
char expectedCountry3[4];
const char *returnedCountry;
GeoIP *gi;
int failed = 0;
int test_num = 1;
int i;
for (i = 0; i < 2; ++i) {
if (0 == i) {
/* Read from filesystem, check for updated file */
gi = GeoIP_open("/usr/share/GeoIP/GeoIP.dat",
GEOIP_STANDARD | GEOIP_CHECK_CACHE);
} else {
/* Read from memory, faster but takes up more memory */
gi = GeoIP_open("/usr/share/GeoIP/GeoIP.dat", GEOIP_MEMORY_CACHE);
} …Run Code Online (Sandbox Code Playgroud) 当我测试双指针行为时,我得到了一个我不太了解的结果.
==>代码1:
int main (int argc , char **argv)
{
if(*argv+1 ==NULL)
{
printf("NULL pointer \n");
exit(0) ;
}
else
{
printf("test double pointer[] : %s \n ",*argv+1);
}
return(0);
}
Run Code Online (Sandbox Code Playgroud)
====>结果1
root@root:/home/aa/test# ./geip 1255
test double pointer[] : /geip
root@root:/home/aa/test#
Run Code Online (Sandbox Code Playgroud)
===>代码2:
int main (int argc , char **argv)
{
if(*argv+9 ==NULL)
{
printf("NULL pointer \n");
exit(0) ;
}
else
{
printf("test double pointer[] : %s \n ",*argv+9);
}
return(0);
}
Run Code Online (Sandbox Code Playgroud)
==>结果2:
root@root:/home/aa/test# ./geip 1255
test double pointer[] : 55 …Run Code Online (Sandbox Code Playgroud)