小编sta*_*k_A的帖子

检查linux OS中打开的所有套接字

我的程序用这个函数打开一个套接字:

sockfd = socket(AF_INET,SOCK_RAW,IPPROTO_ICMP)

完成发送数据后,套接字关闭:

关闭(的sockfd);

但问题是当程序运行不顺畅并且阻塞时.因此插座不会关闭.

如何检查在Linux OS下打开的所有套接字?

c linux

22
推荐指数
3
解决办法
10万
查看次数

如何在linux中创建隐藏文件

在我的程序中,我必须创建一个隐藏文件,以避免删除或修改文件

PATH=/etc/
NAME = file
Run Code Online (Sandbox Code Playgroud)

所以我问c中是否有功能允许这样做?

谢谢

c linux

2
推荐指数
2
解决办法
3万
查看次数

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)

c linux ip-address

1
推荐指数
1
解决办法
334
查看次数

指针的行为; char**argv

当我测试双指针行为时,我得到了一个我不太了解的结果.

==>代码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)

c linux pointers argv

0
推荐指数
1
解决办法
948
查看次数

标签 统计

c ×4

linux ×4

argv ×1

ip-address ×1

pointers ×1