linux網絡編程基礎知識2

一、火狐瀏覽器若遇到訪問超過普通端口80時,出現此地址訪問受限的提示的話,可修改火狐瀏覽器的about:config,新建->字符串,輸入network.security.ports.banned.override,取值範圍設置爲0~65535(簡單方法,取全範圍)

二、循環遍歷目錄
頭文件添加
#include <dirent.h>
#incldue <stdded.h>
int scandir(const char* _dir,struct dirent ***namelist,int (*select),int (*cmp))

例子:

struct dirent **ptr;
int num=scandir(dir,&ptr,NULL,alphasort);
//遍歷
if(int i=0;i<num;i++)
{
	char* name = ptr[i]->d_name;
	。。。。。。
}

注:If you use -std=c99, only functions that are strictly a part of the C99 standard are included by the header files. scandir() is not in the C99 standard. Therefore, you have to set a preprocessor variable to ensure that the function prototype is included. For example, the man page for scandir() indicates that setting the _BSD_SOURCE or _SVID_SOURCE preprocessor variables before you do the #include will fix the problem. Or, you can use #define _GNU_SOURCE which will in turn set quite a few different variables for you (including _BSD_SOURCE and _SVID_SOURCE)
Your code will still compile with the warning and work because C allows you to compile with implicitly defined functions, and the linker will correctly link the call to scandir() to the proper function.
即:若使用C99,則在頭文件中需添加#define GNU_SOURCE
解決方法:gcc -D_GNU_SOURCE -std=c99

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章