122108323 发表于 2012-3-30 10:44:20

STE100P 的UIP协议出问题//////急急急

用的UIP协议。UDP通信。UCOS-II系统驱动
主函数如下:
void uIPMain(void)
{
u8_t i, arptimer,count;
uip_eth_hdr *BUF = (uip_eth_hdr*)uip_buf;
u32 j = 0;


u32 size;


count =0;
/* Initialize the uIP TCP/IP stack. */
uip_init();

/* Initialize the HTTP server. */
httpd_init();

arptimer = 0;

for(j = 0; j<0x100000; j++);

//if(uip_connect(uip_conn->ripaddr, 8080) == NULL) {
//                uip_abort();
//        }


   //uip_ipaddr(ipaddr, 110,184,108,37);
//   uip_ipaddr(ipaddr, sysinformation.MyServerIP,sysinformation.MyServerIP,
//                                                   sysinformation.MyServerIP,sysinformation.MyServerIP);

   uip_ipaddr(ipaddr, TCP_IP,TCP_IP,TCP_IP,TCP_IP);


   //uip_connect(ipaddr, HTONS(8080));
   uip_connect(ipaddr, HTONS(TCP_IP_HTONS));
// uip_connect(ipaddr, HTONS(8080));
/// uip_udp_new(ipaddr, HTONS(8080));

       for(j = 0; j<0x100000; j++);
        //           PlayIntroDelay = 20;
//           while(PlayIntroDelay != 0);
//while(JoyState()!= Up)
while(1)
{
    /* Let the tapdev network device driver read an entire IP packet
       into the uip_buf. If it must wait for more than 0.5 seconds, it
       will return with the return value 0. If so, we know that it is
       time to call upon the uip_periodic(). Otherwise, the tapdev has
       received an IP packet that is to be processed by uIP. */
          //for(j = 0; j<0x500; j++);
          OSTimeDlyHMSM(0,0,0,8);

          count ++;

          if(count >= 100)
          {
          count =0;
                  if(recon == 0)
                  //uip_connect(ipaddr, HTONS(8080));
               // uip_connect(ipaddr, HTONS(TCP_IP_HTONS));
          
          }
          

        //PlayIntroDelay = 1;

        //   while(PlayIntroDelay != 0);
      size = ENET_HandleRxPkt(uip_buf);

      if (size > 0)
      uip_len = size;

      if(uip_len <= 0x0)
      {
      for(i = 0; i < UIP_CONNS; i++)          //tcp 连接
      {
              uip_periodic(i);

         /* If the above function invocation resulted in data that
           should be sent out on the network, the global variable
           uip_len is set to a value > 0. */

           if(uip_len > 0)
         {
            uip_arp_out();

            TransmitPacket();
         }
      }

#if UIP_UDP
      for(i = 0; i < UIP_UDP_CONNS; i++)
      {
        uip_udp_periodic(i);
        /* If the above function invocation resulted in data that
           should be sent out on the network, the global variable
           uip_len is set to a value > 0. */
        if(uip_len > 0)
      {
          uip_arp_out();

          TransmitPacket();
        }
      }
#endif /* UIP_UDP */

      /* Call the ARP timer function every 10 seconds. */
       if(++arptimer == 20)
       {       
          uip_arp_timer();
          arptimer = 0;
       }
    }

    else       //接到数据大于0
    {
      if(BUF->type == htons(UIP_ETHTYPE_IP))        //IP头
      {
          uip_arp_ipin();                  //arp 表
          uip_input();               //数据处理

         /* If the above function invocation resulted in data that
           should be sent out on the network, the global variable
           uip_len is set to a value > 0. */
           if(uip_len > 0)
         {
                 uip_arp_out();          //
             TransmitPacket();          //真正的发送函数
           }
      }
      else if(BUF->type == htons(UIP_ETHTYPE_ARP)) //ARP头
      {
        uip_arp_arpin();//arp 输入

        /* If the above function invocation resulted in data that
           should be sent out on the network, the global variable
           uip_len is set to a value > 0. */       
        if(uip_len > 0)
      {
          TransmitPacket();
        }
      }
    }
}
}

UIP协议两个(或以上)客户端跟同一个服务端器端口通信为什么有一个老是超时重连。

两个客户端老是有一个重连,而且重连是相互交替的,例如我两个客户端的IP尾数分别是20跟22,他们不停的(0.2S)给服务器端口发送数据。服务器显示:先是20的客户端连上了通信正常。22的没连上,过了一会儿(3S)22的连上了,20的却掉线了,再过一会儿20的又重连上了,22的掉线了。无限循环下去。不知道该怎么解决这个问题,求大神相助。我用的是标准的UIP协议。ARM芯片来驱动。只连接一个客户端一点问题都没有。两个客户端就有上述问题,仿真观察 是发送超时,然后连接被关闭。然后又轮询打开。我不知道该怎么改了。
求大神相助。

顺便问一下,UIP协议支持多个客户端同时向一台服务器通信吗

122108323 发表于 2012-3-30 11:45:05

{:mad:}求大神帮我一下

122108323 发表于 2012-3-31 09:50:26

高手未出现,帖子不要沉,顶上来...{:mad:}
页: [1]
查看完整版本: STE100P 的UIP协议出问题//////急急急