中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 基于PXA270嵌入式系統(tǒng)的Socket通信設(shè)計(jì)

        基于PXA270嵌入式系統(tǒng)的Socket通信設(shè)計(jì)

        作者: 時(shí)間:2009-05-18 來源:網(wǎng)絡(luò) 收藏

        3.1 客戶端程序
        客戶端可以向服務(wù)器端發(fā)送連接請(qǐng)求,并且客戶端也可以接收到來自服務(wù)器端發(fā)送回來的數(shù)據(jù)??蛻舳丝梢耘袛喈?dāng)前自己的工作狀態(tài),如連接的建立,啟動(dòng)的成功和數(shù)據(jù)包的個(gè)數(shù)等??蛻舳顺绦?a class="contentlabel" href="http://www.antipu.com.cn/news/listbylabel/label/設(shè)計(jì)">設(shè)計(jì)主要按以下的步驟完成函數(shù)的調(diào)用:
        ①建立自己的(并驗(yàn)證建立成功);
        ②啟動(dòng)連接(并驗(yàn)證建立成功);
        ③返回連接信息;
        ④接收收到的數(shù)據(jù);
        ⑤判斷數(shù)據(jù)的屬性。
        客戶端程序的程序基本流程如圖3所示。

        本文引用地址:http://www.antipu.com.cn/article/152489.htm

        圖3 客戶端程序簡(jiǎn)單示意圖
        客戶端打開通道,并連接到服務(wù)器所在主機(jī)的特定端口,向服務(wù)器發(fā)送請(qǐng)求報(bào)文,等待并接收應(yīng)答,請(qǐng)求結(jié)束后關(guān)閉通道并終止通信??蛻舳酥饕绦蛉缦拢?br /> Int main(int argc,char *argv[])
        if(argc!=3)
        printf(error!!!please enter the remote IP and PORT please!!! the form like 192.168.0.* 4000n);
        mysocket=socket(AF_INET,SOCK_STREAM,0); //建立一個(gè)套接字
        if(mysocket==-1)
        printf(error!!! failed to created the new socket,program end heren);
        printf(OK-- you have successful created a socket named mysocketn);
        return(0); //socket 建立不成功,回初始位置
        connectcheck=connect(mysocket,(struct sockaddr*)addr_remote,sizeof(struct sockaddr));
        //調(diào)用connect函數(shù)連接服務(wù)器端
        if(connectcheck==-1)
        printf(error!!!sorry you have failed to connect the remote server!!try again !program end heren);
        // connect不成功回初始位置
        printf(OK-- Now you have successful connect the server,this server IP =%s,and it's PORT =%s,now you can communicat with this server!!!!!!!n ,argv[1],argv[2])
        //打印服務(wù)器IP地址和端口號(hào)
        while(1)
        bzero(gotbuffer,long);
        number=recv(mysocket,gotbuffer,long,0);
        //調(diào)用阻塞函數(shù)
        if(number==-1)
        printf(error!!! some thing wrong !let you can not got the data form server,program end heren);
        return(0);
        gotbuffer[number]='