这篇教程C++ udp_recv函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中udp_recv函数的典型用法代码示例。如果您正苦于以下问题:C++ udp_recv函数的具体用法?C++ udp_recv怎么用?C++ udp_recv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了udp_recv函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: udp_start/** * Start UDP transfer. */static int udp_start(struct ttcp* ttcp) { ttcp->udp_end_marker_left = 5; ttcp->upcb = udp_new(); if (ttcp->upcb == NULL) { printk("TTCP [%p]: could not allocate pcb/n", ttcp); return -1; } if (ttcp->mode == TTCP_MODE_TRANSMIT) { if (udp_connect(ttcp->upcb, &ttcp->addr, ttcp->port) != ERR_OK) { printk("TTCP [%p]: udp connect failed/n", ttcp); return -1; } udp_send_data(ttcp); } else { udp_recv(ttcp->upcb, udp_recv_cb, ttcp); } return 0;}
开发者ID:4bcat,项目名称:Arduino,代码行数:23,
示例2: IAP_tftp_process_write/** * @brief Processes TFTP write request * @param to: pointer on the receive IP address * @param to_port: receive port number * @retval none */static int IAP_tftp_process_write(struct udp_pcb *upcb, struct ip_addr *to, int to_port){ tftp_connection_args *args = NULL; /* This function is called from a callback, * therefore interrupts are disabled, * therefore we can use regular malloc */ args = mem_malloc(sizeof *args); if (!args) { IAP_tftp_cleanup_wr(upcb, args); return 0; } args->op = TFTP_WRQ; args->to_ip.addr = to->addr; args->to_port = to_port; /* the block # used as a positive response to a WRQ is _always_ 0!!! (see RFC1350) */ args->block = 0; args->tot_bytes = 0; /* set callback for receives on this UDP PCB (Protocol Control Block) */ udp_recv(upcb, IAP_wrq_recv_callback, args); total_count =0; /* init flash */ FLASH_If_Init(); /* erase user flash area */ FLASH_If_Erase(USER_FLASH_FIRST_PAGE_ADDRESS); Flash_Write_Address = USER_FLASH_FIRST_PAGE_ADDRESS; /* initiate the write transaction by sending the first ack */ IAP_tftp_send_ack_packet(upcb, to, to_port, args->block); #ifdef USE_LCD LCD_DisplayStringLine(Line9, (char*)"State: Programming.."); #endif return 0;}
开发者ID:003900107,项目名称:netIAP,代码行数:47,
示例3: LwIPMgr_initial/*..........................................................................*/QState LwIPMgr_initial(LwIPMgr *me, QEvt const *e) { uint8_t macaddr[NETIF_MAX_HWADDR_LEN]; (void)e; /* suppress the compiler warning about unused parameter */ /* Configure the hardware MAC address for the Ethernet Controller */ macaddr[0] = MAC_ADDR0; macaddr[1] = MAC_ADDR1; macaddr[2] = MAC_ADDR2; macaddr[3] = MAC_ADDR3; macaddr[4] = MAC_ADDR4; macaddr[5] = MAC_ADDR5; /* initialize the Ethernet Driver */ me->netif = eth_driver_init((QActive *)me, macaddr); me->ip_addr = 0x00000000U; /* initialize to impossible value */ /* initialize the lwIP applications... */ httpd_init(); /* initialize the simple HTTP-Deamon (web server) */ http_set_ssi_handler(&ssi_handler, ssi_tags, Q_DIM(ssi_tags)); http_set_cgi_handlers(cgi_handlers, Q_DIM(cgi_handlers)); me->upcb = udp_new(); udp_bind(me->upcb, IP_ADDR_ANY, 777U); /* use port 777 for UDP */ udp_recv(me->upcb, &udp_rx_handler, me); QS_OBJ_DICTIONARY(&l_lwIPMgr); QS_OBJ_DICTIONARY(&l_lwIPMgr.te_LWIP_SLOW_TICK); QS_FUN_DICTIONARY(&QHsm_top); QS_FUN_DICTIONARY(&LwIPMgr_initial); QS_FUN_DICTIONARY(&LwIPMgr_running); QS_SIG_DICTIONARY(SEND_UDP_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_SLOW_TICK_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_RX_READY_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_TX_READY_SIG, (QActive *)me); QS_SIG_DICTIONARY(LWIP_RX_OVERRUN_SIG,(QActive *)me); return Q_TRAN(&LwIPMgr_connecting);}
开发者ID:SmartCocktailFactory,项目名称:QP_LWIP_STM32F2xx_eth_DPP_Example,代码行数:42,
示例4: IAP_tftpd_init/** * @brief Creates and initializes a UDP PCB for TFTP receive operation * @param none * @retval none */void IAP_tftpd_init(void){ err_t err; unsigned port = 69; /* 69 is the port used for TFTP protocol initial transaction */ /* create a new UDP PCB structure */ UDPpcb = udp_new(); if (!UDPpcb) { /* Error creating PCB. Out of Memory */ return ; } /* Bind this PCB to port 69 */ err = udp_bind(UDPpcb, IP_ADDR_ANY, port); if (err == ERR_OK) { /* Initialize receive callback function */ udp_recv(UDPpcb, IAP_tftp_recv_callback, NULL); } }
开发者ID:003900107,项目名称:netIAP,代码行数:26,
示例5: sntp_init/** * Initialize this module. * Send out request instantly or after SNTP_STARTUP_DELAY. */voidsntp_init(int tz){ LWIP_DEBUGF(SNTP_DEBUG_WARN_STATE,"Sntp initializing TZ: GMT%s%02d.../n",tz > 0 ? "+" : "",tz); ets_uart_printf("Sntp initializing.../n"); sntp_tz = tz; if (sntp_pcb == NULL) { os_timer_setfn(&ntp_timer,ntp_time_update,NULL); SNTP_RESET_RETRY_TIMEOUT(); sntp_pcb = udp_new(); LWIP_ASSERT("Failed to allocate udp pcb for sntp client", sntp_pcb != NULL); if (sntp_pcb != NULL) { udp_recv(sntp_pcb, sntp_recv, NULL);#if SNTP_STARTUP_DELAY sys_timeout((u32_t)SNTP_STARTUP_DELAY, sntp_request, NULL);#else sntp_request(NULL);#endif } }}
开发者ID:TomerCo,项目名称:ESP8266-AT,代码行数:25,
示例6: udp_echoserver_init/** * @brief Initialize the server application. * @param None * @retval None */void udp_echoserver_init(void){ struct udp_pcb *upcb; err_t err; /* Create a new UDP control block */ upcb = udp_new(); if (upcb) { /* Bind the upcb to the UDP_PORT port */ /* Using IP_ADDR_ANY allow the upcb to be used by any local interface */ err = udp_bind(upcb, IP_ADDR_ANY, UDP_SERVER_PORT); if(err == ERR_OK) { /* Set a receive callback for the upcb */ udp_recv(upcb, udp_echoserver_receive_callback, NULL); } }}
开发者ID:NjordCZ,项目名称:STM32Cube_FW_F1,代码行数:26,
示例7: lwipv4_socket_createstatic socket_error_t lwipv4_socket_create(struct socket *sock, const socket_address_family_t af, const socket_proto_family_t pf, socket_api_handler_t const handler){ switch (af) { case SOCKET_AF_INET4: break; default: return SOCKET_ERROR_BAD_FAMILY; } if (sock == NULL || handler == NULL) return SOCKET_ERROR_NULL_PTR; switch (pf) { case SOCKET_DGRAM: { struct udp_pcb *udp = udp_new(); if (udp == NULL) return SOCKET_ERROR_BAD_ALLOC; sock->stack = SOCKET_STACK_LWIP_IPV4; sock->impl = (void *)udp; udp_recv((struct udp_pcb *)sock->impl, irqUDPRecv, (void *)sock); break; } case SOCKET_STREAM: { struct tcp_pcb *tcp = tcp_new(); if (tcp == NULL) return SOCKET_ERROR_BAD_ALLOC; sock->impl = (void *)tcp; sock->stack = SOCKET_STACK_LWIP_IPV4; tcp_arg(tcp, (void*) sock); tcp_err(tcp, tcp_error_handler); break; } default: return SOCKET_ERROR_BAD_FAMILY; } sock->family = pf; sock->handler = (void*)handler; sock->rxBufChain = NULL; return SOCKET_ERROR_NONE;}
开发者ID:u-blox,项目名称:sal-stack-lwip-ublox-odin-w2,代码行数:40,
示例8: udp_echo_initvoid udp_echo_init(void){ struct udp_pcb * pcb; // get new pcb pcb = udp_new(); if (pcb == NULL) { LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!/n")); return; } // bind to any IP address on port 7 if (udp_bind(pcb, IP_ADDR_ANY, 7) != ERR_OK) { LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!/n")); return; } printf("UDP bind to PORT:7 OK!/r/n"); // set udp_echo_recv() as callback function // for received packets udp_recv(pcb, udp_echo_recv, NULL);}
开发者ID:jeenter,项目名称:CH-K-Lib,代码行数:22,
示例9: tftp_process_write/** * @brief processes tftp write operation * @param upcb: pointer on upd pcb * @param to: pointer on remote IP address * @param to_port: pointer on remote udp port * @param FileName: pointer on filename to be written * @retval error code */int tftp_process_write(struct udp_pcb *upcb, struct ip_addr *to, int to_port, char *FileName){ tftp_connection_args *args = NULL; /* Can not create file */ if (f_open(&file_CR, (const TCHAR*)FileName, FA_CREATE_ALWAYS|FA_WRITE) != FR_OK) { tftp_send_error_message(upcb, to, to_port, TFTP_ERR_NOTDEFINED); tftp_cleanup_wr(upcb, args); return 0; } args = mem_malloc(sizeof *args); if (!args) { tftp_send_error_message(upcb, to, to_port, TFTP_ERR_NOTDEFINED); tftp_cleanup_wr(upcb, args); return 0; } args->op = TFTP_WRQ; args->to_ip.addr = to->addr; args->to_port = to_port; /* the block # used as a positive response to a WRQ is _always_ 0!!! (see RFC1350) */ args->block = 0; args->tot_bytes = 0; /* set callback for receives on this UDP PCB */ udp_recv(upcb, wrq_recv_callback, args); /* initiate the write transaction by sending the first ack */ tftp_send_ack_packet(upcb, to, to_port, args->block); return 0;}
开发者ID:jdaheron,项目名称:GHB,代码行数:47,
示例10: IAP_tftpd_init/** * @brief Creates and initializes a UDP PCB for TFTP receive operation * @param none * @retval none */void IAP_tftpd_init(void){ err_t err; unsigned port = 69; /* 69 is the port used for TFTP protocol initial transaction */ /* create a new UDP PCB structure */ UDPpcb = udp_new(); if (!UDPpcb) { udp_lcd_y += UPDATE_WORD_SIZE + UPDATE_ROW_DISTANCE; lcd_font24(udp_lcd_x,udp_lcd_y,COLOR_POINT,COLOR_BACK,"> C++ udp_remove函数代码示例 C++ udp_new函数代码示例
|