当前位置: 代码迷 >> 单片机 >> 急LWIP移植,客户端与服务器端无法建立连接!该如何解决
  详细解决方案

急LWIP移植,客户端与服务器端无法建立连接!该如何解决

热度:39   发布时间:2016-04-28 15:34:18.0
急!LWIP移植,客户端与服务器端无法建立连接!?
正在搞一个小项目,板子是LM3S8962(周立功的),网上找到一个lwip API 的例子,代码如下:
#include <includes.h>

/*********************************************************************************************************
  CONSTANTS 常量定义
*********************************************************************************************************/
const static uint8 TCP_TestData[]="This is LwIP TCP Client 在Luminary Cortex-M3上的测试!\r\n";

/*********************************************************************************************************
  VARIABLES 变量定义
*********************************************************************************************************/

/*********************************************************************************************************
  函数声明
*********************************************************************************************************/
void TCP_Client_Init();


//  延时
void  Delay(unsigned long  ulVal)
{
    while ( --ulVal  !=  0 );
}
/*********************************************************************************************************
** Function name:      main    
** Descriptions:       系统主函数入口
** input parameters:   无
** output parameters:  无      
** Returned value:      0  
** Created by:    
** Created Date:    2008.8.28
**--------------------------------------------------------------------
** Modified by:         
** Modified date:         
**--------------------------------------------------------------------
*********************************************************************************************************/
int main()
{
  targetInit();
  InitNic();
 
  while(1)
  {
    TCP_Client_Init();
    Delay(1000000UL);  
    Delay(1000000UL); 
    Delay(1000000UL); 
   }
}

/******* 这是一个回调函数,当TCP客户端请求的连接建立时被调用********/
err_t TcpCli_Connected(void *arg,struct tcp_pcb *pcb,err_t err)
{
   tcp_write(pcb,TCP_TestData,sizeof(TCP_TestData),0);      //发送数据
   
   tcp_close(pcb);
   
   return ERR_OK;
}

/*********************************************************************************************************
** Function name:           TCP_Client_Init    
** Descriptions:            TCP客户端的初始化,当需要建立客户端连接时调用
** input parameters:        无
** output parameters:       无      
** Returned value:          0  
** Created by:    
** Created Date:     2008.10.9
  相关解决方案