问题描述:使用
STM32F746Discovery
开发板,使用FreeRTOS,LWIP协议,Netconn API在开发板上建立一个TCP客户端去访问远端服务器,在PC上使用网络助手模拟一个远端网络服务器,开发板能够正常连接收发数据,但是,直接将连网的网线插到开发板上,给网络服务器发送特定数据后却收不到服务器返回的数据。
请教各位大神和版主,这种可以和本地pc进行客户端服务器
通信但是不能和网络服务器进行通信的问题是什么造成的?谢谢大家!!
建立TCP客户端,连接远端服务器的代码如下:
struct netbuf *TCPRecvbuf;
struct netbuf *buf;
sta
tic void http_server_netconn_thread(void *arg)
{
int i=0;
char *string[200];
void *data;
uint16_t len;
struct netconn *conn;
err_t myerr,recv_err;
struct netbuf *TCPNetbuf;
ip4_addr_t serverip;
char Text[] ="GET /BDKJ HTTP/1.0rnUser-Agent: NTRIP GNSSInternetRadio/1.4.10rnAccept: */*rnAuthorization: Basic dXNlcjpwYXNzd29yZA==rnrnrnrn";
IP4_ADDR(&serverip,180,149,145,238);
// IP4_ADDR(&serverip,192,168,0,10);
conn = netconn_new(NETCONN_TCP);
netconn_bind(conn,NULL,NULL);
osDelay(5000);
myerr = netconn_connect(conn,&serverip,8000);
TCPNetbuf = netbuf_new();
netbuf_ref(TCPNetbuf,Text,sizeof(Text));
netconn_write(conn,(void *)&Text,sizeof(Text),NETCONN_NOCOPY);
LCD_UsrLog ("%srn", Text);
netbuf_delete(TCPNetbuf);
// osDelay(1000);
while(1)
{
while(( recv_err = netconn_recv(conn, &buf)) == ERR_OK)
{
do
{
//Get the data pointer and length of the data inside a netbuf.
netbuf_data(buf, &data, &len);
memcpy(string,data,len);
LCD_UsrLog ("The Receive data is: %srn", string);
memset(string,0,len);
}
//Move the current data pointer of a packet buffer contained in a netbuf to the next part.
while (netbuf_next(buf) >= 0);
netbuf_delete(buf);
}
}
}