lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Re:about lwip socket() and connect()??


From: xcb
Subject: [lwip-users] Re:about lwip socket() and connect()??
Date: Thu, 26 Aug 2004 13:40:44 +0800

lwip-users:
        i have test ethernetif ,it has the same problem(connect return 0 but 
sever not accept immediately).
My code:

        sys_init();
        mem_init();
        memp_init();
        pbuf_init();

        sem = sys_sem_new(0);
        tcpip_init(tcpip_init_done, &sem);
        sys_sem_wait(sem);
        sys_sem_free(sem);

        netif_init();

        IP4_ADDR(&gw, 192,100,100,2);
        IP4_ADDR(&ipaddr, 192,100,100,167);
        IP4_ADDR(&netmask, 255,255,255,0);
        
        netif_set_default(netif_add(&nif,&ipaddr, &netmask, &gw,NULL, 
ethernetif_init,
                tcpip_input));
        netif_set_up(&nif);

        sys_thread_new(SnifferPktThread, NULL, TCPIP_THREAD_PRIO+1);
        //it is a thread that capture pkt from networkIf,and pass to 
ethernetif_input();
        sys_msleep(1000);

        //test socket
        {
                int sock;
                struct sockaddr_in ListSvAddr;
                char strIPaddr[20];
                int iNet;
                char sendStr[500];
                
                sys_msleep(1000);
                sprintf(strIPaddr,"192.100.100.99");
                memset(&ListSvAddr,0,sizeof(ListSvAddr));
                ListSvAddr.sin_family=AF_INET;
                ListSvAddr.sin_port=htons(5906);
                ListSvAddr.sin_addr.s_addr=inet_addr(strIPaddr);
                
                sock = socket(PF_INET, SOCK_STREAM, 0);
                iNet = connect(sock,(struct sockaddr *)&ListSvAddr, 
sizeof(ListSvAddr)); //return 0 but server no accept
                
                sprintf(sendStr,"test tcp socket!!!");
                send(sock,sendStr,strlen(sendStr),0);            //sever accept 
and recv sendStr.
   }

if code of test socket run in window ,no this problem.  what is the problem??





reply via email to

[Prev in Thread] Current Thread [Next in Thread]