lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] socket: LWIP_ACCEPT problem?


From: Piero 74
Subject: [lwip-users] socket: LWIP_ACCEPT problem?
Date: Wed, 5 Mar 2008 16:13:53 +0100

Hi all.

I'm testing socket on lwip 130rc1

this is a piece of my code:

  // Create a new tcp connection handle
  //----------------------------------------------------------
  sockfd = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
  serv_addr.sin_family = AF_INET;
  serv_addr.sin_addr.s_addr = INADDR_ANY;
  serv_addr.sin_port = htons(20000);
  bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
  //    setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, (char*)&bOptVal, bOptLen);
  listen(sockfd, 0);
  //----------------------------------------------------------

  // Loop forever
  while(1)
  {
    // Wait for connection.
    //------------------------------------------------------   
    newsockfd = accept(sockfd, &addr, &addrlen);
    bOptVal = TRUE;
    //------------------------------------------------------  
    for (i=0; i<10; i++)
    {
      // send 10 hello world!
      lwip_write(newsockfd, provatx, 12);
    }       
   
    // close connection
    close(newsockfd);
  }

I have a simple client on pc running windows.

If the client fixs his local port, accept function accept connection only the first time, after seems it doesn't accept.

If my client changes its local port for EVERY attempt, accept works weel!!!

What is the problem???

bye,
Piero



reply via email to

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