中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

簡單個人博客模板網(wǎng)站網(wǎng)站內(nèi)容管理系統(tǒng)

簡單個人博客模板網(wǎng)站,網(wǎng)站內(nèi)容管理系統(tǒng),如何安裝織夢做的網(wǎng)站,免費的h5制作平臺文章目錄 1. TCP通信 客戶端(關鍵配置)2. TCP 服務端配置3. UDP 點播通信4. UDP 廣播通信5. UIP_UDP_APPCALL 里邊的處理example6. TCP數(shù)據(jù)處理 ,UIP_APPCALL調(diào)用的函數(shù) UIP_APPCALL TCP的數(shù)據(jù)都在這個宏定義的函數(shù)里進行數(shù)據(jù)處理的 UDP 數(shù)據(jù)…

文章目錄

  • 1. TCP通信 客戶端(關鍵配置)
  • 2. TCP 服務端配置
  • 3. UDP 點播通信
  • 4. UDP 廣播通信
  • 5. UIP_UDP_APPCALL 里邊的處理example
  • 6. TCP數(shù)據(jù)處理 ,UIP_APPCALL調(diào)用的函數(shù)

UIP_APPCALL TCP的數(shù)據(jù)都在這個宏定義的函數(shù)里進行數(shù)據(jù)處理的
UDP 數(shù)據(jù)在#define UIP_UDP_APPCALL udp_appcall 中處理

1. TCP通信 客戶端(關鍵配置)

// 定義 MAC 地址(6 字節(jié))static const uint8_t mac_address[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};// 設置 MAC 地址memcpy(ethaddr.addr, mac_address, sizeof(mac_address));uip_setethaddr(ethaddr);uip_ipaddr_t ipaddr;uip_init();                          // uIP初始化uip_ipaddr(ipaddr, 192, 168, 1, 137); // 設置本地設置IP地址uip_sethostaddr(ipaddr);uip_ipaddr(ipaddr, 192, 168, 1, 1); // 設置網(wǎng)關IP地址(其實就是你路由器的IP地址)uip_setdraddr(ipaddr);uip_ipaddr(ipaddr, 255, 255, 255, 0); // 設置網(wǎng)絡掩碼uip_setnetmask(ipaddr);uip_ipaddr_t ipaddr;uip_ipaddr(&ipaddr, 192, 168, 1, 100); // 設置TCP Server IP為192.168.1.100uip_connect(&ipaddr, htons(8080));     // 端口為1400

2. TCP 服務端配置

    uip_ipaddr_t ipaddr, remote_ip;// 定義 MAC 地址(6 字節(jié))static const uint8_t mac_address[6] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55};// 設置 MAC 地址memcpy(ethaddr.addr, mac_address, sizeof(mac_address));uip_setethaddr(ethaddr);// uIP初始化uip_init();/* ARP table initialize. */uip_arp_init();/*-----------UIP-TCP-Server---------------------*/// 設置本地設置IP地址uip_ipaddr(ipaddr, 192, 168, 1, 137);uip_sethostaddr(ipaddr);// 設置網(wǎng)關IP地址(其實就是你路由器的IP地址)uip_ipaddr(ipaddr, 192, 168, 1, 1);uip_setdraddr(ipaddr);// 設置網(wǎng)絡掩碼uip_ipaddr(ipaddr, 255, 255, 255, 0);uip_setnetmask(ipaddr);// 設置 遠程客戶端IP為192.168.1.100uip_ipaddr(&remote_ip, 192, 168, 1, 100);uip_connect(&remote_ip, htons(7090)); /*連接到遠程客戶端的通信端口為7090 *//* We start to listen for connections on TCP port 8090. */uip_listen(HTONS(8090));/*-----------UIP-TCP-Server---------------------*/

3. UDP 點播通信

uip_ipaddr_t remote_addr;struct uip_udp_conn *udp_conn;// 設置遠程主機的 IP 地址為 192.168.1.100uip_ipaddr(&remote_addr, 192, 168, 1, 100);// 創(chuàng)建到 remote 192.168.1.100:1215 的 UDP 連接udp_conn = uip_udp_new(&remote_addr, HTONS(1215));if (udp_conn == NULL){UART1_Send_String("Failed to create UDP connection! \r\n");}else{uip_udp_bind(udp_conn, HTONS(1234)); // 綁定本地端口 1234}

4. UDP 廣播通信

UDP 廣播需要打開這個宏

#ifndef UIP_CONF_BROADCAST
#define UIP_BROADCAST 1
#else /* UIP_CONF_BROADCAST /
#define UIP_BROADCAST UIP_CONF_BROADCAST
#endif /
UIP_CONF_BROADCAST */

   /*Broadcast IP ADDR*/uip_ipaddr_t Broadcast_addr;struct uip_udp_conn *udp_conn;// UDP廣播地址,本局域網(wǎng)中的所有設備uip_ipaddr(&Broadcast_addr, 255, 255, 255, 255);/*UDP 廣播端口1212*/udp_conn = uip_udp_new(&Broadcast_addr, HTONS(0));if (udp_conn == NULL){UART1_Send_String("Failed to create UDP connection! \r\n");}else{uip_udp_bind(udp_conn, HTONS(3956));}

5. UIP_UDP_APPCALL 里邊的處理example

    /*udp rx data*/if (uip_newdata()){#if (USE_GVCP==1)gvcp_discover_callback();#elsechar *data = (char *)uip_appdata;int len = uip_datalen();memset(udp_server_databuf, 0, 1500);memcpy((char *)udp_server_databuf,(char *)uip_appdata,uip_len);// 打印接收到的數(shù)據(jù)UART1_Send_String("[UDP_RX]:");UART1_Send_String(udp_server_databuf);UART1_Send_String("\r\n");#endif}// 當需要重發(fā)、新數(shù)據(jù)到達、數(shù)據(jù)包送達,通知uip發(fā)送數(shù)據(jù)if (uip_rexmit() || uip_newdata() || uip_poll()){#if (USE_GVCP==1)#else// 將數(shù)據(jù)復制到 uIP 的應用層數(shù)據(jù)緩沖區(qū)memcpy(uip_appdata, message, sizeof(message));// 發(fā)送數(shù)據(jù)uip_udp_send(sizeof(message));  // 發(fā)送的字節(jié)數(shù)#endif}

6. TCP數(shù)據(jù)處理 ,UIP_APPCALL調(diào)用的函數(shù)

/*** @brief 這是一個TCP 服務器應用回調(diào)函數(shù)。*  該函數(shù)通過UIP_APPCALL(tcp_demo_appcall)調(diào)用,實現(xiàn)Web Server的功能.* 當uip事件發(fā)生時,UIP_APPCALL函數(shù)會被調(diào)用,根據(jù)所屬端口(1200),確定是否執(zhí)行該函數(shù)。* 例如 : 當一個TCP連接被創(chuàng)建時、有新的數(shù)據(jù)到達、數(shù)據(jù)已經(jīng)被應答、數(shù)據(jù)需要重發(fā)等事件*/
void tcp_server_demo_appcall(void)
{// 連接終止if (uip_aborted()){uip_log("TCP_Server Aborted!\r\n"); // 打印log}// 連接超時if (uip_timedout()){uip_log("TCP_Server Timeout!\r\n"); // 打印log}// 連接關閉if (uip_closed()){uip_log("TCP_server CLOSED!\r\n"); // 打印log}// 連接成功if (uip_connected()){uip_log("TCP_Server Connected OK!\r\n"); // 打印log}// 發(fā)送的數(shù)據(jù)成功送達if (uip_acked()){// uip_log("TCP_Server ACK OK!\r\n");}else{/*數(shù)據(jù)發(fā)送失敗*/// uip_log("TCP_Server NOT ACK!\r\n");}/* 接收到一個新的TCP數(shù)據(jù)包,收到客戶端發(fā)過來的數(shù)據(jù)*/if (uip_newdata()){memcpy(&request, uip_appdata, uip_len);if (PROTOCOL_REQUEST_MAGIC == request.header.nMagic){// uip_log("Recive APP SDK Update!\r\n");protocol_handle_request(&request, &response);}else{uip_log("Recive APP Bin data ERROR! \r\n");}uip_send(&response, response.buf.len);}}/*** @brief TCP應用接口函數(shù)(UIP_APPCALL)*  完成TCP服務(包括server和client)*/
void tcp_demo_appcall(void)
{switch (uip_conn->lport) // 本地監(jiān)聽端口80和1200{case HTONS(8090):tcp_server_demo_appcall();// uip_log("tcp_demo_appcall Local 8080 TCP Server!! \r\n");}#ifdef TCP_Client/*tcp client use */switch (uip_conn->rport) // 遠程連接8080端口{case HTONS(8080): // 一旦有來自遠程主機的信息,就調(diào)用此函數(shù)// tcp_client_demo_appcall();// uip_log("tcp_demo_appcall Remote 8080 TCP Client!! \r\n");break;}#endif}
http://www.risenshineclean.com/news/46187.html

相關文章:

  • 京東網(wǎng)站建設步驟關鍵詞排名關鍵詞快速排名
  • 做網(wǎng)站獨立云服務器什么意思網(wǎng)址大全瀏覽器
  • 網(wǎng)站建設平臺漢龍網(wǎng)頁制作官方網(wǎng)站
  • 自己做的個人網(wǎng)站無法備案廣東東莞今日最新消息
  • 新手學做網(wǎng)站必備軟件seo技術培訓課程
  • 網(wǎng)站支付功能怎么做全自動推廣引流軟件免費
  • 日本做暖網(wǎng)站推廣網(wǎng)站要注意什么
  • 寧德住房和城鄉(xiāng)建設部網(wǎng)站怎樣做網(wǎng)絡推廣營銷
  • 新網(wǎng)站怎么做權重國際新聞軍事最新消息
  • 廣東網(wǎng)站制作百度客服人工電話24小時
  • 拼多多網(wǎng)站分析百度網(wǎng)站登錄
  • 做類似交易貓的網(wǎng)站如何優(yōu)化網(wǎng)頁
  • 六安網(wǎng)站建設哪家靠譜線下推廣宣傳方式有哪些
  • 網(wǎng)站眾籌該怎么做公眾號軟文是什么意思
  • 忍不住在樓道里面做免費網(wǎng)站千萬不要學網(wǎng)絡營銷
  • 網(wǎng)站下方一般放什么原因宣傳推廣策略
  • 計算機專業(yè)里面哪個專業(yè)最好攀枝花seo
  • 營銷型網(wǎng)站一套東莞seo網(wǎng)站優(yōu)化排名
  • 哈爾濱住房和城鄉(xiāng)建設廳網(wǎng)站品牌推廣方案怎么寫
  • 鐵道部網(wǎng)上訂票網(wǎng)站素材網(wǎng)站分析案例
  • 家居飾品網(wǎng)站建設論文怎么在百度上推廣自己的產(chǎn)品
  • 動態(tài)網(wǎng)站與靜態(tài)網(wǎng)站的區(qū)別北京百度seo服務
  • 020模版網(wǎng)站制作網(wǎng)絡營銷的推廣方式
  • 51自學網(wǎng)官方網(wǎng)站百度廣告電話號碼
  • 各大網(wǎng)站做推廣的廣告怎么做做引流的公司是正規(guī)的嗎
  • 肇慶網(wǎng)站建設公司凡科小程序
  • 網(wǎng)站設計開發(fā)人員國家高新技術企業(yè)名單
  • 電影網(wǎng)站建設多少錢百度網(wǎng)站入口
  • 做網(wǎng)站排名費用多少百度風云榜明星
  • 手機網(wǎng)站有什么區(qū)別嗎廣告推廣平臺代理