Advertisement
Guest User

Untitled

a guest
Sep 10th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1.  
  2. uint8_t test_data[1000];
  3. void tcpSend(void *arg)
  4. {
  5.     struct netconn *xNetConn = NULL;
  6.  
  7.     //struct ip_addr local_ip;
  8.     struct ip_addr remote_ip;
  9.     err_t err;
  10.  
  11.     uint32_t i;
  12.  
  13.     for(i=0; i<sizeof(test_data); i++)
  14.         test_data[i] = 0x30+i%10;
  15.  
  16.     IP4_ADDR(&remote_ip, 192, 168, 1, 1);
  17.     while(1)
  18.     {
  19.         xNetConn = netconn_new ( NETCONN_TCP );
  20.         if ( xNetConn == NULL )
  21.         {
  22.             /* No memory for new connection? */
  23.             continue;
  24.         }
  25.  
  26.         err = netconn_connect ( xNetConn, &remote_ip, 8000 );
  27.  
  28.         if (err == ERR_OK )
  29.         {
  30.             while(1)
  31.             {
  32.                 err = netconn_write(xNetConn, test_data, sizeof(test_data), NETCONN_NOCOPY);
  33.                 if (err != ERR_OK)
  34.                     printf("tcpSend: netconn_write: error \"%s\"\n", lwip_strerr(err));
  35.                 //msDelay(10);
  36.             }
  37.         }
  38.         netconn_delete ( xNetConn );
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement