Browse Source

fix udpecho send bug.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@314 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong 15 years ago
parent
commit
4c56e26952
1 changed files with 8 additions and 5 deletions
  1. 8 5
      net/apps/udpecho.c

+ 8 - 5
net/apps/udpecho.c

@@ -4,13 +4,13 @@
 
 
 void udpecho_entry(void *parameter)
 void udpecho_entry(void *parameter)
 {
 {
-	static struct netconn *conn;
-	static struct netbuf *buf;
-	static struct ip_addr *addr;
-	static unsigned short port;
+	struct netconn *conn;
+	struct netbuf *buf;
+	struct ip_addr *addr;
+	unsigned short port;
 
 
 	conn = netconn_new(NETCONN_UDP);
 	conn = netconn_new(NETCONN_UDP);
-	netconn_bind(conn, NULL, 7);
+	netconn_bind(conn, IP_ADDR_ANY, 7);
 
 
 	while(1)
 	while(1)
 	{
 	{
@@ -22,6 +22,9 @@ void udpecho_entry(void *parameter)
 
 
         /* send the data to buffer */
         /* send the data to buffer */
 		netconn_connect(conn, addr, port);
 		netconn_connect(conn, addr, port);
+
+		/* reset address, and send to client */
+		buf->addr = RT_NULL;
 		netconn_send(conn, buf);
 		netconn_send(conn, buf);
 
 
         /* release buffer */
         /* release buffer */