C 編程調試集

來源:互聯網
上載者:User

標籤:

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 編程調試集

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.