lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #47321] How to exit from a lwip_recvfrom non blocking


From: PIPON
Subject: [lwip-devel] [bug #47321] How to exit from a lwip_recvfrom non blocking loop
Date: Wed, 02 Mar 2016 15:01:53 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0

URL:
  <http://savannah.nongnu.org/bugs/?47321>

                 Summary: How to exit from a lwip_recvfrom non blocking loop
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: harvey
            Submitted on: mer. 02 mars 2016 15:01:52 GMT
                Category: sockets/netconn
                Severity: 3 - Normal
              Item Group: Feature Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 
            lwIP version: 1.4.1

    _______________________________________________________

Details:

Hello

I'm using a simple telnet server, but I did not know how to exit my loop when
a RST is received from the client...

I then changed lwip_recvfrom function

  do {
...
        if (sock->conn->pcb.tcp->state == ESTABLISHED) 
            {
            LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning 
EWOULDBLOCK\n",
s));
            sock_set_errno(sock, EWOULDBLOCK);
            return -1;
            }
        else
            return -2;
...
    }


So I can detect there is no more connections.


void vBasicSocketsCommandInterpreterTask(void *pvParameters)
{
...
    lSocket = lwip_socket(AF_INET, SOCK_STREAM, 0);
    if (lSocket >= 0) {
        if (lwip_bind(lSocket, (struct sockaddr *) &sLocalAddr,
sizeof(sLocalAddr)) < 0) {
            lwip_close(lSocket);
            vTaskDelete(NULL);
        }
       
        for (;;) {
            lClientFd = lwip_accept(lSocket, (struct sockaddr *) &client_addr,
(u32_t *) &lAddrLen);
            if (lClientFd > 0L) {
                do {
                    lBytes = lwip_recv(lClientFd, &cInChar, sizeof(cInChar),
MSG_DONTWAIT);
                    if (lBytes == -2L) {
                        Quit = 1;
                    } else {
                        if (lBytes > 0L) {
                            switch (Telnet_State) {
                                case TS_DATA:
                                    break;
                                case TS_IAC:
                                    break;
                            }
                        }//if (lBytes > 0L)
                    }
                    vTaskDelay(TELNET_TASK_BREATH);
                } while (Quit == 0);
                Quit = 0;
                lwip_close(lClientFd);
            }// if (lClientFd > 0L)
            vTaskDelay(TELNET_TASK_BREATH);
        }// for (;;)
    }// if (lSocket >= 0)
    vTaskDelete(NULL);
}


I didn't find the way with the lwip_getsockopt.....

Regards




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?47321>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/




reply via email to

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