您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ tcp_poll函数代码示例

51自学网 2021-06-03 08:42:23
  C++
这篇教程C++ tcp_poll函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中tcp_poll函数的典型用法代码示例。如果您正苦于以下问题:C++ tcp_poll函数的具体用法?C++ tcp_poll怎么用?C++ tcp_poll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了tcp_poll函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: tcp_poll

err_t EthernetClient::do_poll(void *arg, struct tcp_pcb *cpcb){	EthernetClient *client = static_cast<EthernetClient*>(arg);	if(client->_connected) {		if(cpcb->keep_cnt_sent++ > 4) {			cpcb->keep_cnt_sent = 0;			/* Stop polling */			tcp_poll(cpcb, NULL, 0);			tcp_abort(cpcb);			return ERR_OK;		}		/* Send tcp keep alive probe */		tcp_keepalive(cpcb);		return ERR_OK;	}	/* We only end up here if the connection failed to close	 * in an earlier call to tcp_close */	err_t err = tcp_close(cpcb);	if (err != ERR_OK) {		/* error closing, try again later in poll (every 2 sec) */		tcp_poll(cpcb, do_poll, 4);		return err;	}	return err;}
开发者ID:Nandopolis,项目名称:Energia,代码行数:29,


示例2: ftp_poll

/*****************************************************************************************************************************函数名称:	 	ftp_poll**函数功能:	 	**入口参数:**返回参数:***************************************************************************************************************************/void ftp_poll(FTP_INFO *pftpInfo,BYTE interval){	if(eRAW == pftpInfo->attri)	{		if(eCtr == pftpInfo->ctrOrMsg)		{			tcp_poll(pftpInfo->ftpRAWControl,pftpInfo->poll,interval);		}		else if(eMsg == pftpInfo->ctrOrMsg)		{			tcp_poll(pftpInfo->ftpRAWDataMsg,pftpInfo->poll,interval);		}	}}
开发者ID:liudonghua7914,项目名称:FlyMcu,代码行数:20,


示例3: tcp_err

void EthernetClient::stop(){	if(cpcb == NULL)		return;	_connected = false;	/* Stop frees any resources including any unread buffers */	err_t err;	if(cpcb) {		tcp_err(cpcb, NULL);		if(cs->p) {			tcp_recved(cpcb, cs->p->tot_len);			pbuf_free(cs->p);			cs->p = NULL;		}		err = tcp_close(cpcb);	}	if (err != ERR_OK) {		/* Error closing, try again later in poll (every 2 sec) */		tcp_poll(cpcb, do_poll, 4);	} else {		cpcb = NULL;	}}
开发者ID:Nandopolis,项目名称:Energia,代码行数:28,


示例4: altcp_tcp_close

static err_taltcp_tcp_close(struct altcp_pcb *conn){  struct tcp_pcb *pcb;  if (conn == NULL) {    return ERR_VAL;  }  ALTCP_TCP_ASSERT_CONN(conn);  pcb = (struct tcp_pcb *)conn->state;  if (pcb) {    err_t err;    tcp_poll_fn oldpoll = pcb->poll;    altcp_tcp_remove_callbacks(pcb);    err = tcp_close(pcb);    if (err != ERR_OK) {      /* not closed, set up all callbacks again */      altcp_tcp_setup_callbacks(conn, pcb);      /* poll callback is not included in the above */      tcp_poll(pcb, oldpoll, pcb->pollinterval);      return err;    }    conn->state = NULL; /* unsafe to reference pcb after tcp_close(). */  }  altcp_free(conn);  return ERR_OK;}
开发者ID:0xc0170,项目名称:mbed,代码行数:26,


示例5: tcp_server_accept

//lwIP tcp_accept()的回调函数err_t tcp_server_accept(void *arg,struct tcp_pcb *newpcb,err_t err){	err_t ret_err;	struct tcp_server_struct *es;  	LWIP_UNUSED_ARG(arg);	LWIP_UNUSED_ARG(err);	tcp_setprio(newpcb,TCP_PRIO_MIN);//设置新创建的pcb优先级	es=(struct tcp_server_struct*)mem_malloc(sizeof(struct tcp_server_struct)); //分配内存 	if(es!=NULL) //内存分配成功	{		es->state=ES_TCPSERVER_ACCEPTED;  	//接收连接		es->pcb=newpcb;		es->p=NULL;				tcp_arg(newpcb,es);		tcp_recv(newpcb,tcp_server_recv);	//初始化tcp_recv()的回调函数		tcp_err(newpcb,tcp_server_error); 	//初始化tcp_err()回调函数		tcp_poll(newpcb,tcp_server_poll,1);	//初始化tcp_poll回调函数		tcp_sent(newpcb,tcp_server_sent);  	//初始化发送回调函数		  		tcp_server_flag|=1<<5;				//标记有客户端连上了		lwipdev.remoteip[0]=newpcb->remote_ip.addr&0xff; 		//IADDR4		lwipdev.remoteip[1]=(newpcb->remote_ip.addr>>8)&0xff;  	//IADDR3		lwipdev.remoteip[2]=(newpcb->remote_ip.addr>>16)&0xff; 	//IADDR2		lwipdev.remoteip[3]=(newpcb->remote_ip.addr>>24)&0xff; 	//IADDR1 		ret_err=ERR_OK;	}else ret_err=ERR_MEM;
开发者ID:FeatherHunter,项目名称:STM32F4,代码行数:28,


示例6: espconn_server_close

/****************************************************************************** * FunctionName : espconn_server_close * Description  : The connection shall be actively closed. * Parameters   : arg -- Additional argument to pass to the callback function *                pcb -- the pcb to close * Returns      : none*******************************************************************************/static void ICACHE_FLASH_ATTRespconn_server_close(void *arg, struct tcp_pcb *pcb,uint8 type){    err_t err;    espconn_msg *psclose = arg;	psclose->pcommon.pcb = pcb;	/*avoid recalling the disconnect function*/	tcp_recv(pcb, NULL);	if(type ==0)		err = tcp_close(pcb);	else		{tcp_abort(pcb); err = ERR_OK;}    if (err != ERR_OK) {        /* closing failed, try again later */        tcp_recv(pcb, espconn_server_recv);    } else {        /* closing succeeded */        tcp_poll(pcb, NULL, 0);        tcp_sent(pcb, NULL);        tcp_err(pcb, NULL);        /*switch the state of espconn for application process*/        psclose->pespconn->state = ESPCONN_CLOSE;        ets_post(espconn_TaskPrio, SIG_ESPCONN_CLOSE, (uint32_t)psclose);	}}
开发者ID:Nicholas3388,项目名称:LuaNode,代码行数:35,


示例7: http_accept

/*-----------------------------------------------------------------------------------*/static err_thttp_accept(void *arg, struct tcp_pcb *pcb, err_t err){    struct http_state *hs;    /* Allocate memory for the structure that holds the state of the       connection. */    hs = mem_malloc(sizeof(struct http_state));    if (hs == NULL)    {        return ERR_MEM;    }    /* Initialize the structure. */    hs->file = NULL;    hs->left = 0;    /* Tell TCP that this is the structure we wish to be passed for our       callbacks. */    tcp_arg(pcb, hs);    /* Tell TCP that we wish to be informed of incoming data by a call       to the http_recv() function. */    tcp_recv(pcb, http_recv);    tcp_err(pcb, conn_err);    tcp_poll(pcb, http_poll, 10);    return ERR_OK;}
开发者ID:sun182,项目名称:therme,代码行数:32,


示例8: _lwip_tcp_accept_finished

// "Poll" (idle) callback to be called ASAP after accept callback// to execute Python callback function, as it can't be executed// from accept callback itself.STATIC err_t _lwip_tcp_accept_finished(void *arg, struct tcp_pcb *pcb){    lwip_socket_obj_t *socket = (lwip_socket_obj_t*)arg;    tcp_poll(pcb, NULL, 0);    exec_user_callback(socket);    return ERR_OK;}
开发者ID:learnforpractice,项目名称:micropython,代码行数:10,


示例9: _connect_cb

AsyncClient::AsyncClient(tcp_pcb* pcb): _connect_cb(0), _connect_cb_arg(0), _discard_cb(0), _discard_cb_arg(0), _sent_cb(0), _sent_cb_arg(0), _error_cb(0), _error_cb_arg(0), _recv_cb(0), _recv_cb_arg(0), _timeout_cb(0), _timeout_cb_arg(0), _pcb_busy(false), _pcb_sent_at(0), _close_pcb(false), _ack_pcb(true), _rx_last_packet(0), _rx_since_timeout(0), _ack_timeout(ASYNC_MAX_ACK_TIME), _connect_port(0), prev(NULL), next(NULL), _in_lwip_thread(false){    _pcb = pcb;    if(_pcb){        _rx_last_packet = millis();        tcp_arg(_pcb, this);        tcp_recv(_pcb, &_tcp_recv);        tcp_sent(_pcb, &_tcp_sent);        tcp_err(_pcb, &_tcp_error);        tcp_poll(_pcb, &_tcp_poll, 1);    }}
开发者ID:RitterRBC,项目名称:Arduino,代码行数:35,


示例10: http_accept

static err_t http_accept(void *arg, tcp_pcb *pcb, err_t err){  LWIP_UNUSED_ARG(arg);  LWIP_UNUSED_ARG(err);  tcp_setprio(pcb, TCP_PRIO_MIN);  //RepRapNetworkMessage("http_accept/n");  HttpState *hs = (HttpState*)mem_malloc(sizeof(HttpState));  if (hs == NULL)  {	  RepRapNetworkMessage("Out of memory!/n");	  return ERR_MEM;  }  /* Initialize the structure. */  hs->pcb = pcb;  hs->file = NULL;  hs->left = 0;  hs->retries = 0;  hs->sendingRs = NULL;  tcp_accepted(listening_pcb);	// tell TCP to accept further connections  tcp_arg(pcb, hs);				// tell TCP that this is the structure we wish to be passed for our callbacks  tcp_recv(pcb, http_recv);		// tell TCP that we wish to be informed of incoming data by a call to the http_recv() function  tcp_err(pcb, conn_err);  tcp_poll(pcb, http_poll, 4);  return ERR_OK;}
开发者ID:DannyGH,项目名称:RepRapFirmware,代码行数:30,


示例11: tcp_poll

void NetworkTransaction::Close(){	tcp_pcb *pcb = cs->pcb;	tcp_poll(pcb, NULL, 4);	tcp_recv(pcb, NULL);	closeRequested = true;}
开发者ID:AltairResearch,项目名称:RepRapFirmware,代码行数:7,


示例12: lwip_bind

int lwip_bind(int s, struct sockaddr *name, socklen_t namelen) {	sockfd_t	* fd;	struct ip_addr	ip;	int		port, rv = 0;	s = sock_for_fd(s);	if (s < 0) {		errno = EBADF;		return -1;	}	fd = fds + s;	// Make sure it's an internet address we understand.	if (namelen != sizeof(struct sockaddr_in)) {		errno = ENAMETOOLONG;		return -1;	}	// Get access	mutex_lock(fd->mutex);	// Copy it over	memcpy(&fd->name, name, namelen);	// Convert this to an lwIP-happy format	ip.addr = ((struct sockaddr_in *)name)->sin_addr.s_addr;	port = ((struct sockaddr_in *)name)->sin_port;	// Are we TCP or UDP?	switch (fd->type) {	case SOCK_STREAM:		fd->tcppcb = tcp_new();		tcp_arg(fd->tcppcb, (void *)s);		tcp_recv(fd->tcppcb, recv_tcp);		tcp_sent(fd->tcppcb, sent_tcp);		tcp_poll(fd->tcppcb, poll_tcp, 4);	// 4 == 4 TCP timer intervals		tcp_err(fd->tcppcb, err_tcp);		if (tcp_bind(fd->tcppcb, &ip, ntohs(port)) != ERR_OK) {			if (tcp_close(fd->tcppcb) != ERR_OK)				tcp_abort(fd->tcppcb);			fd->tcppcb = NULL;			errno = EINVAL;			rv = -1; goto out;		}		break;	case SOCK_DGRAM:		fd->udppcb = udp_new();		udp_recv(fd->udppcb, recv_udp, (void *)s);		udp_bind(fd->udppcb, &ip, ntohs(port));		break;	default:		assert( 0 );		errno = EINVAL;		rv = -1; goto out;	}out:	mutex_unlock(fd->mutex);	return rv;}
开发者ID:foreverlikeyou9999,项目名称:kos-ports,代码行数:60,


示例13: tcpecho_raw_accept

static err_ttcpecho_raw_accept(void *arg, struct tcp_pcb *newpcb, err_t err){  err_t ret_err;  struct tcpecho_raw_state *es;  LWIP_UNUSED_ARG(arg);  if ((err != ERR_OK) || (newpcb == NULL)) {    return ERR_VAL;  }  /* Unless this pcb should have NORMAL priority, set its priority now.     When running out of pcbs, low priority pcbs can be aborted to create     new pcbs of higher priority. */  tcp_setprio(newpcb, TCP_PRIO_MIN);  es = (struct tcpecho_raw_state *)mem_malloc(sizeof(struct tcpecho_raw_state));  if (es != NULL) {    es->state = ES_ACCEPTED;    es->pcb = newpcb;    es->retries = 0;    es->p = NULL;    /* pass newly allocated es to our callbacks */    tcp_arg(newpcb, es);    tcp_recv(newpcb, tcpecho_raw_recv);    tcp_err(newpcb, tcpecho_raw_error);    tcp_poll(newpcb, tcpecho_raw_poll, 0);    tcp_sent(newpcb, tcpecho_raw_sent);    ret_err = ERR_OK;  } else {    ret_err = ERR_MEM;  }  return ret_err;}
开发者ID:yarrick,项目名称:lwip-contrib,代码行数:34,


示例14: ident_accept

/*-----------------------------------------------------------------------------------*/static err_tident_accept(void *arg, struct tcp_pcb *pcb, err_t err){  struct ident_state *hs;  /* Allocate memory for the structure that holds the state of the     connection. */  hs = mem_malloc(sizeof(struct ident_state));  if(hs == NULL) {    printf("ident_accept: Out of memory/n");    return ERR_MEM;  }    /* Initialize the structure. */  memset (hs, 0, sizeof (*hs));  if (sizeof (hs->remote) != sizeof (pcb->remote_ip))    die ("sizeof (hs.remote) != sizeof (pcb->remote_ip)");  memcpy (&hs->remote, &pcb->remote_ip, sizeof (hs->remote));  /* Tell TCP that this is the structure we wish to be passed for our     callbacks. */  tcp_arg(pcb, hs);  /* Tell TCP that we wish to be informed of incoming data by a call     to the ident_recv() function. */  tcp_recv(pcb, ident_recv);  tcp_err(pcb, conn_err);    tcp_poll(pcb, ident_poll, 10);  return ERR_OK;}
开发者ID:kingcope,项目名称:LikeOS,代码行数:34,


示例15: INT_PROTECT_INIT

void EthernetClient::stop() {	/* Stop frees any resources including any unread buffers */	err_t err;	INT_PROTECT_INIT(oldLevel);	/* protect the code from preemption of the ethernet interrupt servicing */	INT_PROTECT(oldLevel);	struct tcp_pcb * cpcb_copy = (tcp_pcb *) SYNC_FETCH_AND_NULL(&cs->cpcb);	struct pbuf * p_copy = (pbuf *) SYNC_FETCH_AND_NULL(&cs->p);	_connected = false;	cs->port = 0;	if (cpcb_copy) {		tcp_err(cpcb_copy, NULL);		if (p_copy) {			tcp_recved(cpcb_copy, p_copy->tot_len);			pbuf_free(p_copy);		}		err = tcp_close(cpcb_copy);		if (err != ERR_OK) {			/* Error closing, try again later in poll (every 2 sec) */			tcp_poll(cpcb_copy, do_poll, 4);		}	}	INT_UNPROTECT(oldLevel);}
开发者ID:energia,项目名称:tivac-core,代码行数:32,


示例16: TCP_accept

/**  * @brief  This function is the implementation of tcp_accept LwIP callback  * @param  arg: not used  * @param  newpcb: pointer on tcp_pcb struct for the newly created tcp connection  * @param  err: not used   * @retval err_t: error status  */static err_t		TCP_accept(void *arg, struct tcp_pcb *newpcb, err_t err) {		err_t ret_err;		TCP *es;				LWIP_UNUSED_ARG(arg);		LWIP_UNUSED_ARG(err);		tcp_setprio(newpcb, TCP_PRIO_MIN);					/* set priority for the newly accepted tcp connection newpcb */		es = (TCP *)mem_malloc(sizeof(TCP));				/* allocate structure es to maintain tcp connection informations */		if (es != NULL) {			es->state = ES_ACCEPTED;			es->pcb = newpcb;			es->tx = NULL;			es->rx = NULL;			tcp_arg(newpcb, es);											/* pass newly allocated es structure as argument to newpcb */			tcp_recv(newpcb, TCP_recv);								/* initialize lwip tcp_recv callback function for newpcb  */ 			tcp_err(newpcb, TCP_error);								/* initialize lwip tcp_err callback function for newpcb  */			tcp_poll(newpcb, TCP_poll, 1);						/* initialize lwip tcp_poll callback function for newpcb */			es->io=((func*)arg)(NULL);								// prvi klic			if(es->io) {															// tole je lahko tut drugace				es->f=(func *)arg;				_thread_add(es->f,es->io,"user app.",0);				_thread_add(_tcp_flush,es,"tcp flush",0);			}						ret_err = ERR_OK;		} else {			ret_err = ERR_MEM;												/* return memory error */		}		return ret_err;  	}
开发者ID:yallawalla,项目名称:stm32,代码行数:39,


示例17: http_accept

// Called when a new connection was accepted.static err_thttp_accept(void *arg, struct tcp_pcb *pcb, err_t err){    struct http_state *hs;    CYG_TEST_INFO("Incoming connection");    tcp_setprio(pcb, TCP_PRIO_MIN);    // Allocate memory for the structure that holds the state of the connection    hs = mem_malloc(sizeof(struct http_state));    if (hs == NULL)        return ERR_MEM;    // Initialize the structure    hs->file = NULL;    hs->left = 0;    hs->retries = 0;    // Tell TCP that this is the structure we wish to be passed for our    // callbacks    tcp_arg(pcb, hs);    // Register callbacks    tcp_recv(pcb, http_recv);    tcp_err(pcb, http_err);    tcp_poll(pcb, http_poll, 4);    CYG_TEST_INFO("Connection accepted");    return ERR_OK;}
开发者ID:Palantir555,项目名称:ecos-mars-zx3,代码行数:33,


示例18: _connect_cb

AsyncClient::AsyncClient(tcp_pcb* pcb):  _connect_cb(0)  , _connect_cb_arg(0)  , _discard_cb(0)  , _discard_cb_arg(0)  , _sent_cb(0)  , _sent_cb_arg(0)  , _error_cb(0)  , _error_cb_arg(0)  , _recv_cb(0)  , _recv_cb_arg(0)  , _timeout_cb(0)  , _timeout_cb_arg(0)  , _refcnt(0)  , _pcb_busy(false)  , _pcb_sent_at(0)  , _close_pcb(false)  , _rx_last_packet(0)  , _rx_since_timeout(0)  , prev(NULL)  , next(NULL){  _pcb = pcb;  if(pcb){    tcp_setprio(_pcb, TCP_PRIO_MIN);    tcp_arg(_pcb, this);    tcp_recv(_pcb, (tcp_recv_fn) &_s_recv);    tcp_sent(_pcb, &_s_sent);    tcp_err(_pcb, &_s_error);    tcp_poll(_pcb, &_s_poll, 1);  }}
开发者ID:2fatdotco,项目名称:sxsw2016-arduinoLampLibraries,代码行数:32,


示例19: echo_accept

err_techo_accept(void *arg, struct tcp_pcb *newpcb, err_t err){  err_t ret_err;  struct echo_state *es;  /* commonly observed practive to call tcp_setprio(), why? */  tcp_setprio(newpcb, TCP_PRIO_MIN);  es = mem_malloc(sizeof(struct echo_state));  if (es != NULL)  {    es->state = ES_ACCEPTED;    es->pcb = newpcb;    es->retries = 0;    es->p = NULL;    /* pass newly allocated es to our callbacks */    tcp_arg(newpcb, es);    tcp_recv(newpcb, echo_recv);    tcp_err(newpcb, echo_error);    tcp_poll(newpcb, echo_poll, 0);    ret_err = ERR_OK;  }  else  {    ret_err = ERR_MEM;  }  return ret_err;  }
开发者ID:NKSG,项目名称:INTER_MANET_NS3,代码行数:29,


示例20: netio_close

static voidnetio_close(void *arg, struct tcp_pcb *pcb){  err_t err;  struct netio_state *ns = arg;  ns->state = NETIO_STATE_DONE;  tcp_recv(pcb, NULL);  err = tcp_close(pcb);  if (err != ERR_OK) {    /* closing failed, try again later */    tcp_recv(pcb, netio_recv);  } else {    /* closing succeeded */#if NETIO_USE_STATIC_BUF != 1    if(ns->buf_ptr != NULL){      mem_free(ns->buf_ptr);    }#endif    tcp_arg(pcb, NULL);    tcp_poll(pcb, NULL, 0);    tcp_sent(pcb, NULL);    if (arg != NULL) {      mem_free(arg);    }  }}
开发者ID:comrid1987,项目名称:jb3500,代码行数:28,


示例21: tcp_echoclient_connection_close

/**  * @brief This function is used to close the tcp connection with server  */static void tcp_echoclient_connection_close(TM_TCPCLIENT_t* client, uint8_t success) {	/* Remove callbacks from PCB */	if (client->pcb != NULL) {		tcp_recv(client->pcb, NULL);		tcp_sent(client->pcb, NULL);		tcp_poll(client->pcb, NULL, 0);	}		/* Close tcp connection */	if (client->pcb != NULL) {		tcp_close(client->pcb);	}		/* Free pcb */	mem_free(client->pcb);		/* Increase number of connections */	TM_ETHERNET.ClientConnections++;		/* In case connection was successfull */	if (success) {		/* Increase successfull connections counter */		TM_ETHERNET.ClientSuccessfullConnections++;	}		/* Free client, it's not real free, only free flag is set */	/* Called before connection callback, so user can make a new connection */	/* inside connection closed callback */	tcp_client_free(client);		/* Call user function if defined */	TM_ETHERNETCLIENT_ConnectionClosedCallback(client, success);}
开发者ID:win95,项目名称:Fansipanplus,代码行数:36,


示例22: lwiperf_tcp_accept

/** This is called when a new client connects for an iperf tcp session */static err_tlwiperf_tcp_accept(void *arg, struct tcp_pcb *newpcb, err_t err){  lwiperf_state_tcp_t *s, *conn;  if ((err != ERR_OK)  || (newpcb == NULL) || (arg == NULL)) {    return ERR_VAL;  }  s = (lwiperf_state_tcp_t*)arg;  conn = (lwiperf_state_tcp_t*)LWIPERF_ALLOC(lwiperf_state_tcp_t);  if (conn == NULL) {    return ERR_MEM;  }  memset(conn, 0, sizeof(lwiperf_state_tcp_t));  conn->base.tcp = 1;  conn->base.server = 1;  conn->base.related_server_state = &s->base;  conn->server_pcb = s->server_pcb;  conn->conn_pcb = newpcb;  conn->time_started = sys_now();  conn->report_fn = s->report_fn;  conn->report_arg = s->report_arg;  /* setup the tcp rx connection */  tcp_arg(newpcb, conn);  tcp_recv(newpcb, lwiperf_tcp_recv);  tcp_poll(newpcb, lwiperf_tcp_poll, 2U);  tcp_err(conn->conn_pcb, lwiperf_tcp_err);  lwiperf_list_add(&conn->base);  return ERR_OK;}
开发者ID:michas2,项目名称:l4re-snapshot,代码行数:33,


示例23: lwiperf_tcp_close

/** Close an iperf tcp session */static voidlwiperf_tcp_close(lwiperf_state_tcp_t* conn, enum lwiperf_report_type report_type){  err_t err;  lwip_tcp_conn_report(conn, report_type);  lwiperf_list_remove(&conn->base);  if (conn->conn_pcb != NULL) {    tcp_arg(conn->conn_pcb, NULL);    tcp_poll(conn->conn_pcb, NULL, 0);    tcp_sent(conn->conn_pcb, NULL);    tcp_recv(conn->conn_pcb, NULL);    tcp_err(conn->conn_pcb, NULL);    err = tcp_close(conn->conn_pcb);    if (err != ERR_OK) {      /* don't want to wait for free memory here... */      tcp_abort(conn->conn_pcb);    }  } else {    /* no conn pcb, this is the server pcb */    err = tcp_close(conn->server_pcb);    LWIP_ASSERT("error", err != ERR_OK);  }  LWIPERF_FREE(lwiperf_state_tcp_t, conn);}
开发者ID:michas2,项目名称:l4re-snapshot,代码行数:26,


示例24: atcp_start

/** * Start TCP transfer. */static int atcp_start(struct ttcp* ttcp) {	err_t err = ERR_OK;	ttcp->tpcb = tcp_new();	if (ttcp->tpcb == NULL) {		WARN("TTCP [%p]: could not allocate pcb/n", ttcp);		return -1;	}	ttcp->payload = malloc(ttcp->buflen);	if (ttcp->payload == NULL) {		WARN("TTCP [%p]: could not allocate payload/n", ttcp);		return -1;	}	tcp_arg(ttcp->tpcb, ttcp);	atcp_init_pend_flags();	if (ttcp->mode == TTCP_MODE_TRANSMIT) {		tcp_err(ttcp->tpcb, atcp_conn_cli_err_cb);		tcp_recv(ttcp->tpcb, atcp_recv_cb);		tcp_sent(ttcp->tpcb, tcp_data_sent);		tcp_poll(ttcp->tpcb, atcp_poll_conn, 4);		_connected = false;		INFO_TCP("[tpcb]-%p payload:%p/n", ttcp->tpcb, ttcp->payload);		DUMP_TCP_STATE(ttcp);		if (tcp_connect(ttcp->tpcb, &ttcp->addr, ttcp->port, tcp_connect_cb)				!= ERR_OK) {			WARN("TTCP [%p]: tcp connect failed/n", ttcp);			return -1;		}	} else {		INFO_TCP("BEFORE BIND ttcp:%p lpcb:%p pcb:%p/n", ttcp, ttcp->lpcb, ttcp->tpcb);		INFO_TCP("[tpcb]-local:%d remote:%d state:%d/n", ttcp->tpcb->local_port,				ttcp->tpcb->remote_port, ttcp->tpcb->state);		err = tcp_bind(ttcp->tpcb, IP_ADDR_ANY, ttcp->port);		if (err != ERR_OK){			WARN("TTCP [%p]: bind failed err=%d Port already used/n", ttcp, err);			return -1;		}		ttcp->lpcb = tcp_listen(ttcp->tpcb);		if (ttcp->lpcb == NULL) {			WARN("TTCP [%p]: listen failed/n", ttcp);			return -1;		}		if (ttcp->lpcb == ttcp->tpcb ) {			WARN("TTCP [%p]: listen failed tpcb [%p] in listen mode/n", ttcp, ttcp->tpcb);			return -1;		}		DUMP_TCP_STATE(ttcp);		tcp_accept(ttcp->lpcb, atcp_accept_cb);	}	return 0;}
开发者ID:4bcat,项目名称:Arduino,代码行数:62,


示例25: altcp_tcp_set_poll

/* "virtual" functions calling into tcp */static voidaltcp_tcp_set_poll(struct altcp_pcb *conn, u8_t interval){  if (conn != NULL) {    struct tcp_pcb *pcb = (struct tcp_pcb *)conn->state;    ALTCP_TCP_ASSERT_CONN(conn);    tcp_poll(pcb, altcp_tcp_poll, interval);  }}
开发者ID:0xc0170,项目名称:mbed,代码行数:10,


示例26: debugf

void TcpConnection::close(){	if (tcp == NULL) return;	debugf("TCP connection closing");	tcp_poll(tcp, staticOnPoll, 1);	tcp_arg(tcp, NULL); // reset pointer to close connection on next callback	tcp = NULL;}
开发者ID:BorntraegerMarc,项目名称:SmingRTOS,代码行数:9,


示例27: altcp_tcp_remove_callbacks

static voidaltcp_tcp_remove_callbacks(struct tcp_pcb *tpcb){  tcp_arg(tpcb, NULL);  tcp_recv(tpcb, NULL);  tcp_sent(tpcb, NULL);  tcp_err(tpcb, NULL);  tcp_poll(tpcb, NULL, tpcb->pollinterval);}
开发者ID:0xc0170,项目名称:mbed,代码行数:9,


示例28: tcp_echoclient_connected

/**  * @brief Function called when TCP connection established  */static err_t tcp_echoclient_connected(void *arg, struct tcp_pcb *tpcb, err_t err) {	uint16_t length;	TM_TCPCLIENT_t* client;	/* Client is passed as arguments */	client = (TM_TCPCLIENT_t *)arg;	if (err == ERR_OK) {		/* We are connected */		client->state = CLIENT_CONNECTED;		/* Get HTTP request from user */		length = TM_ETHERNETCLIENT_CreateHeadersCallback(client, (char *)data, sizeof(data));				/* Check if length = 0 */		if (length == 0) {			/* Close connection */			tcp_echoclient_connection_close(client, 1);						/* Return */			return ERR_CONN;		}		/* Allocate pbuf */		client->p_tx = pbuf_alloc(PBUF_TRANSPORT, strlen((char *)data), PBUF_POOL);		/* If we have memory for buffer */		if (client->p_tx) {			/* Call user function */			TM_ETHERNETCLIENT_ConnectedCallback(client);						/* copy data to pbuf */			pbuf_take(client->p_tx, (char *)data, length);			/* initialize LwIP tcp_recv callback function */ 			tcp_recv(client->pcb, tcp_echoclient_recv);			/* initialize LwIP tcp_sent callback function */			tcp_sent(client->pcb, tcp_echoclient_sent);			/* initialize LwIP tcp_poll callback function */			tcp_poll(client->pcb, tcp_echoclient_poll, 1);			/* Set new error handler */			tcp_err(client->pcb, tcp_echoclient_error);						/* send data */			tcp_echoclient_send(client);			/* Return OK */			TM_Client[0] = client[0];			return ERR_OK;		}	} else {		/* close connection */		tcp_echoclient_connection_close(client, 0);	}	return err;}
开发者ID:win95,项目名称:Fansipanplus,代码行数:59,



注:本文中的tcp_poll函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ tcp_read函数代码示例
C++ tcp_output函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。