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

<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è)計應(yīng)用 > 基于PXA270嵌入式系統(tǒng)的Socket通信設(shè)計

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

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

        客戶端與服務(wù)器端進程的作用是非對稱的,因此編碼不同。同時,服務(wù)器進程一般是先于客戶請求請求而啟動的,只要運行,該服務(wù)進程一直存在,直到正?;驈娖冉K止。服務(wù)器端主要程序如下:
        mysocket=socket(AF_INET,SOCK_STREAM,0);
        //建立新的套接字
        if(mysocket==-1)
        printf(error!!! failed to created mysocketn);
        return(0); //socket建立不成功,回初始位置
        mybindcheck=bind(mysocket,(struct sockaddr*)addr_local,sizeof(struct sockaddr));
        if(mybindcheck==-1)
        printf(error!!!failed to bind the IP and port with mysocketn);
        return(0);

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

        圖4 服務(wù)器端程序簡單示意圖
        { printf(OK--you have successed bind your IP with port %dn,port);
        listencheck=listen(mysocket,howmany);
        if(listencheck==-1)
        printf(error!!! you have failed listen this port,program end heren);
        return(0); //調(diào)用監(jiān)聽函數(shù)
        sin_size=sizeof(struct sockaddr_in);
        newsocket=accept(mysocket,(struct sockaddr*)addr_remote,sin_size);
        //調(diào)用接收函數(shù)
        if(newsocket==-1)
        printf(error!!!failed to got remote connect this server,program end heren);
        return(0); //建立新的socket失敗返回
        printf(OK-- now have created the newsocket to use this own connection,use this communicate with clint%sn,inet_ntoa(addr_remote.sin_addr),port);
        printf(OK-- server have successed got connect from clint IP = %s,port = %d,now connecting is running;n,inet_ntoa(addr_remote.sin_addr),port)
        pid_t pid;
        pid=fork(); //調(diào)用fork()建立子進程
        if(pid>0)
        printf(OK-- i am a father procces,child proccess will continue for you,it's ID= %d,now end newsock and use old socket to listen again................. n,pid);
        close(newsocket);
        printf(OK-- i am a child procces,i am responsible for this new communicate,blow i will do for connectn);
        printf(OK-- please enter your data which you want to send n);
        while(1)
        bzero(sendbuffer,long);
        scanf(%s,sendbuffer);
        sendcheck=send(newsocket,sendbuffer,strlen(sendbuffer),0); //發(fā)送數(shù)據(jù)
        if(sendcheck==-1)
        printf(error!!!failed to send to remoten);
        close(newsocket);
        else
        printf(OK--now you have send %d byte data to remote!!!pleases send again!!!!n,sendcheck);

        linux操作系統(tǒng)文章專題:linux操作系統(tǒng)詳解(linux不再難懂)

        tcp/ip相關(guān)文章:tcp/ip是什么




        評論


        相關(guān)推薦

        技術(shù)專區(qū)

        關(guān)閉