lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Socket read/write and threads


From: Alain Mouette
Subject: Re: [lwip-users] Socket read/write and threads
Date: Tue, 12 Jan 2010 13:47:47 -0200
User-agent: Thunderbird 2.0.0.23 (X11/20090812)

I can send you a snipplet that works fo me, with FreeRTOS

The select is a bit of black magic, I don't remember exactly how it works, but I do remember that it is standard linux or socket programing.

I also needed a queue for outgoing messages, so that it is sent from the correct thread.

-----
        fd_set rfds;
        struct timeval tv;
...
        xStatus = xQueueReceive ( xQueueSendToServer, &pMess, xTickToWait);
        if ( xStatus == pdPASS )
                lwip_send(sock, pMess->mBuf,  pMess->mLen, 0);
        // Use select to check if there is data
        FD_ZERO(&rfds);
        FD_SET(sock,&rfds);
        tv.tv_sec=0;tv.tv_usec=0;
        lwip_select(sock+1,&rfds,NULL,NULL,&tv);
        if (FD_ISSET(sock,&rfds)){
                // *CAN ONLY READ* if ther is data...
                if ((tam=lwip_read(sock,msgBuf, MAX_MSG))>0){
                        MessageFormServer(msgBuf, tam, sock);
                }
        }
------

Alain




reply via email to

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