標籤:
gcc rw.c
rw.c:75:6: warning: conflicting types for ‘process_conn_server’
void process_conn_server(int s)
^
rw.c:64:4: note: previous implicit declaration of ‘process_conn_server’ was here
process_conn_server(sc);
^
上述問題是 缺少函數的預定義
void process_conn_server(int s);
主機CPU及作業系統的千差萬別,主機的位元組序不能做到統一,但對網路上傳輸的變數,它的值必須有一個統一的表示,網路位元組序指多位元組變數在網路傳輸時的表示方法
網路位元組序是指多位元組變數在網路上的傳輸時的表示
網路位元組序用高端位元組序
網路位元組序使用高端 小端位元組序變數在網路傳輸變數的時候需要進行位元組序的轉換,大端位元組序的變數則不需要進行轉換
程式設計方便,使用者的程式與平台無關,linux作業系統提供了如下函數進行位元組序的轉換
#include <arpa/inet.h>
uint32_t htonl(uint32_t hostlong); /*主機位元組序到網路位元組序的長整型*/
uint16_t htons(uint16_t hostshort);
uint32_t ntonl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
host to net long;
uint32_t htonl(uint32_t hostlong);
uint32_t unsigned 32 int
hostlong
netlong
hostshort
netshort
函數傳入的變數為需要轉換的變數,函數傳入的,結構是一個等位型別,通過value來賦值,通過byte數組來進行位元組序轉換
value 賦值,通過byte數組來進行位元組序轉換
C 編程調試集