linux網路程式設計基礎api與核心內tc/ip協議族關係。
1. socket位址api
ip位址及埠對,代表tcp通訊中的一方,稱為socket位址。
socket就像pipe一樣,代表的是乙個檔案描述符。可以用socket()來建立。
參考
#include /* see notes */
#include int socket(int domain, int type, int protocol);
返回乙個檔案描述符。
注意,與pipe不同的是,socket可以用來在無關的程序甚至是通過network使得兩個不同機器的程序間進行通訊。
參考sockets are the primary meansof communicating with other machines; telnet, rlogin, ftp, talk, and the other familiar network programs use sockets.
2.socket 基礎api
sys/socket.h
在這裡3.網路資訊api
主機名和ip位址的轉換,服務名和埠號之間的轉換。在netdb.h中。
網路程式設計基礎API
網路位元組序 1.tcp ip協議規定,網路資料流應採用大端位元組序 0x12345678 小端儲存 78儲存在低位址 大端儲存 12儲存在低位址 網路位元組序和主機位元組序的轉換 include uint32 t htonl uint32 t hostlong uint16 t htons uin...
linux網路程式設計基礎api
socket系統呼叫,成功返回乙個socket檔案描述符,失敗返回 1並設定errno bind命名套接字,成功返回0,失敗返回 1並設定errno listen監聽socket,成功返回0,失敗返回 1並設定errno accept從listen監聽佇列中接受乙個連線,成功返回新的socket,失...
網路程式設計學習筆記 基礎
網路程式設計學習記錄 socket被視為檔案的一種,網路程式設計中的資料傳輸同樣使用檔案i o的相關函式。int open const char path,int flag 成功返回檔案描述符,失敗返回 1 path為檔名的字串位址 flag為檔案開啟模式,可選引數如下 例子 fd open dat...