一江春水向東流

          做一個有思想的人,期待與每一位熱愛思考的人交流,您的關(guān)注是對我最大的支持。

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            44 隨筆 :: 139 文章 :: 81 評論 :: 0 Trackbacks
          ?

          socket編程中需要用到的頭文件

          sys/types.h:數(shù)據(jù)類型定義

          sys/socket.h:提供socket函數(shù)及數(shù)據(jù)結(jié)構(gòu)

          netinet/in.h:定義數(shù)據(jù)結(jié)構(gòu)sockaddr_in

          arpa/inet.h:提供IP地址轉(zhuǎn)換函數(shù)

          netdb.h:提供設(shè)置及獲取域名的函數(shù)

          sys/ioctl.h:提供對I/O控制的函數(shù)

          sys/poll.h:提供socket等待測試機(jī)制的函數(shù)

          ?

          其他在網(wǎng)絡(luò)程序中常見的頭文件

          unistd.h:提供通用的文件、目錄、程序及進(jìn)程操作的函數(shù)

          errno.h:提供錯誤號errno的定義,用于錯誤處理

          fcntl.h:提供對文件控制的函數(shù)

          time.h:提供有關(guān)時間的函數(shù)

          crypt.h:提供使用DES加密算法的加密函數(shù)

          pwd.h:提供對/etc/passwd文件訪問的函數(shù)

          shadow.h:提供對/etc/shadow文件訪問的函數(shù)

          pthread.h:提供多線程操作的函數(shù)

          signal.h:提供對信號操作的函數(shù)

          sys/wait.h、sys/ipc.h、sys/shm.h:提供進(jìn)程等待、進(jìn)程間通訊(IPC)及共享內(nèi)存的函數(shù)

          ?

          建議: 在編寫網(wǎng)絡(luò)程序時,可以直接使用下面這段頭文件代碼

          #include <unistd.h>
          #include <sys/types.h>
          #include <sys/socket.h>
          #include <netdb.h>
          #include <stdio.h>
          #include <stdlib.h>
          #include <string.h>
          #include <ctype.h>
          #include <errno.h>
          #include <malloc.h>
          #include <netinet/in.h>
          #include <arpa/inet.h>
          #include <sys/ioctl.h>
          #include <stdarg.h>
          #include <fcntl.h>
          #include <fcntl.h>
          ?

          涉及到用戶權(quán)限及密碼驗證問題時加入如下語句:
          #include <shadow.h>
          #include <crypt.h>
          #include <pwd.h>

          需要注意的是,應(yīng)該在編譯時鏈接加密算法庫,即增加編譯選項:
          -lcrypt

           ?

          涉及到文件及時間操作加入如下語句:
          #include <sys/time.h>
          #include <utime.h>
          #include <time.h>
          #include <sys/stat.h>
          #include <sys/file.h>
          ?

          涉及到多進(jìn)程操作時加入如下語句:
          #include <sys/wait.h>
          #include <sys/ipc.h>
          #include <sys/shm.h>
          #include <signal.h>

          ?

          涉及到多線程操作時加入如下語句:
          #include <pthread.h>
          #include <sys/poll.h>
          需要注意的是,應(yīng)該在編譯時鏈接線程庫,即增加編譯選項:
          -lthread

          posted on 2007-08-24 20:54 allic 閱讀(3353) 評論(1)  編輯  收藏 所屬分類: TCP/IP 開發(fā)

          評論

          # re: socket編程中需要用到的頭文件[未登錄] 2010-05-30 02:49 han
          windows下有這些東西么
          matata@sohu.com  回復(fù)  更多評論
            

          主站蜘蛛池模板: 晋江市| 蒙阴县| 湖口县| 东兰县| 宜黄县| 甘洛县| 佳木斯市| 宁远县| 武鸣县| 青岛市| 余江县| 铅山县| 吴江市| 灵璧县| 湖口县| 突泉县| 临漳县| 定边县| 贞丰县| 巩义市| 灵丘县| 当雄县| 本溪市| 永平县| 奈曼旗| 双流县| 葵青区| 宣恩县| 新疆| 工布江达县| 德州市| 博客| 南丰县| 个旧市| 阿合奇县| 钟祥市| 铅山县| 宜昌市| 濮阳县| 汉源县| 万载县|