最近刚开始建立TCP服务器,可是新建一个TCP总是失败,代码如下,各位大神给看一下,跪谢!
#define TCPSERVER_TASK_PRIO 5
#define TCPSERVER_STK_SIZE 512
__align(8) static OS_STK TCPSERVER_TASK_STK[TCPSERVER_STK_SIZE];
void tcpserver_task(void *pdata);
void tcpserver_task(void *pdata)
{
pdata=pdata;
servercommand_tcpserver_init();
}
err_t servercommand_tcpserver_init(void)
{
err_t err;
pboardconfig_t pboardconfig = fsdata_get_boardconfig();
conn = netconn_new(NETCONN_TCP);
if(!conn)
printf("conn = NULL
");
err = netconn_bind(conn,IP_ADDR_ANY,pboardconfig->cmdport-1);
if(err != ERR_OK)
printf("绑定失败
");
netconn_listen(conn);
conn->recv_timeout = 10;
}
conn = netconn_new(NETCONN_TCP);的结果总是失败,打印“conn = NULL” |