搜索
bottom↓
回复: 2

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

[复制链接]

出0入0汤圆

发表于 2012-3-30 10:44:20 | 显示全部楼层 |阅读模式
用的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[0],sysinformation.MyServerIP[1],
//                                                   sysinformation.MyServerIP[2],sysinformation.MyServerIP[3]);

   uip_ipaddr(ipaddr, TCP_IP[0],TCP_IP[1],TCP_IP[2],TCP_IP[3]);


   //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协议支持多个客户端同时向一台服务器通信吗

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x

阿莫论坛20周年了!感谢大家的支持与爱护!!

知道什么是神吗?其实神本来也是人,只不过神做了人做不到的事情 所以才成了神。 (头文字D, 杜汶泽)

出0入0汤圆

 楼主| 发表于 2012-3-30 11:45:05 | 显示全部楼层
求大神帮我一下

出0入0汤圆

 楼主| 发表于 2012-3-31 09:50:26 | 显示全部楼层
高手未出现,帖子不要沉,顶上来...
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片。注意:要连续压缩2次才能满足要求!!】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-7-24 02:14

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

快速回复 返回顶部 返回列表