毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> 嵌入式 >> 正文

uip_close()主动断开客户端连接没反应

更新时间:2013-11-24:  来源:毕业论文

使用uip1.0协议栈中的uip_close()主动断开客户端连接没反应,也就是客户端收不到断开消息,我的断开处理是在
uip_len = enc28j60_packet_receive(uip_buf, UIP_BUFSIZE );
if (uip_len > 0)
{              
  if(DATABUF->type == htons(UIP_ETHTYPE_IP))
  {           
    uip_arp_ipin();
    uip_input();
    if(uip_len > 0)
    {          
      uip_arp_out();
      enc28j60_packet_send(uip_buf, uip_len);           
    }  
  }
  else if(DATABUF->type == htons(UIP_ETHTYPE_ARP))
  {    
    uip_arp_arpin();
    if(uip_len > 0)
    enc28j60_packet_send(uip_buf, uip_len);
  }
}
else
{
//在这里处理断开连接,加了心跳的断开处理,但是断开没任何反应客户端仍然可以发送数据及UIP可以收取数据,希望大家能帮下忙解决,在这先谢谢大家。   
}

 *********************************************/ #include <avr/io.h>  #include "ip_arp_udp.h"  #include "enc28j60.h"  #include "timeout.h"  #include "avr_compat.h"  #include "net.h"  #include "stdlib.h"    // please modify the following two lines. mac and ip have to be unique  // in your local area network. You can not have the same numbers in  // two devices:  static uint8_t mymac[6] = {0x13,0x33,0x37,0x71,0x77,0x20};  static uint8_t myip[4] = {192,168,1,10};  static uint16_t myport =1200; // listen port for udp  // how did I get the mac addr? Translate the first 3 numbers into ascii is: TUX    #define BUTTON_PORT PORTD  #define BUTTON_PIN PIND  #define BUTTON_BIT PD2    #define BUFFER_SIZE 250  static uint8_t buf[BUFFER_SIZE+1];    int main(void){                      uint16_t plen;          uint8_t i=0;          uint8_t payloadlen=0;          char message[100]={'/','e','l','l','o',0,0,0,',',0,0};                    // set the clock speed to 8MHz          // set the clock prescaler. First write CLKPCE to enable setting of clock the          // next four instructions.          CLKPR=(1<<CLKPCE);          CLKPR=0; // 8 MHZ                    /* enable PB0, reset as output */         DDRB|= (1<<DDB0);            /* set output to gnd, reset the ethernet chip */         PORTB &= ~(1<<PB0);          delay_ms(20);          /* set output to Vcc, reset inactive */         PORTB|= (1<<PB0);          delay_ms(100);                    // LED          /* enable PB1, LED as output */         DDRB|= (1<<DDB1);            /* set output to Vcc, LED off */         PORTB|= (1<<PB1);                    //Enable pullup on pin D          PORTD|= (1<<PD0);            /*initialize enc28j60*/         enc28j60Init(mymac);          delay_ms(20);                    /* Magjack leds configuration, see enc28j60 datasheet, page 11 */         // LEDB=yellow LEDA=green          //          // 0x476 is PHLCON LEDA=links status, LEDB=receive/transmit          // enc28j60PhyWrite(PHLCON,0b0000 0100 0111 01 10);          enc28j60PhyWrite(PHLCON,0x476);          delay_ms(20);                    /* set output to GND, red LED on */         PORTB &= ~(1<<PB1);          i=1;                    //init the ethernet/ip layer:          init_ip_arp_udp(mymac,myip);            while(1){                  // get the next new packet:                  plen = enc28j60PacketReceive(BUFFER_SIZE, buf);                    /*plen will be unequal to zero if there is a valid                   * packet (without crc error) */                 if(plen==0){                          continue;                  }                  // arp is broadcast if unknown but a host may also                  // verify the mac address by sending it to                  // a unicast address.                  if(eth_type_is_arp_and_my_ip(buf,plen)){                          make_arp_answer_from_request(buf,plen);                          continue;                  }                  // check if ip packets (icmp or udp) are for us:                  if(eth_type_is_ip_and_my_ip(buf,plen)==0){                          continue;                  }                                    if (i){                          /* set output to Vcc, LED off */                         PORTB|= (1<<PB1);                          i=0;                  }else{                          /* set output to GND, LED on */                         PORTB &= ~(1<<PB1);                          i=1;                  }                                              if(buf[IP_PROTO_P]==IP_PROTO_ICMP_V && buf[ICMP_TYPE_P]==ICMP_TYPE_ECHOREQUEST_V){                          // a ping packet, let's send pong                          make_echo_reply_from_request(buf,plen);                          continue;                  }                  if (buf[IP_PROTO_P]==IP_PROTO_UDP_V){                          payloadlen=buf[UDP_LEN_L_P]-UDP_HEADER_LEN;                          if (buf[UDP_DATA_P]=='t' && payloadlen==12){                                //itoa(buf,message,10);                                while(1){                                   if (bit_is_clear(PIND,PD0)){                                       make_udp_reply_from_request(buf,message,16,myport);                                        delay_ms(50);                                        while(bit_is_clear(PIND,PD0))                                           {                                           }                                        delay_ms(50);                                        }                                  }                          }                  }          }          return (0);  }

由客户端主动连接,通信,断开都正常。

但是,UIP的服务端有时候不进入某些消息回调。

我经常有碰到,连接中断消息、连接断开消息、通信ACK消息。有接收不到的

只能在应用层上再做一个处理。 

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。