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: Nicolas Pinault
Subject: Re: [lwip-users] Socket read/write and threads
Date: Mon, 11 Jan 2010 16:00:01 +0100
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)


 Well, there is a "nasty" but effective way to do that, although please note I am against it unless all else has failed and you must do it.
It simply involves adding a dummy socket to one or more of the fd_sets, and triggering it when you want the select call to return.
The ugly trigger is closing the socket. This could involve several problems but has worked for me before (use the read_fds for this).
You're right, this is a kind of nasty thing.
A more subtle trigger is a read or write to the socket. You should define a DATAGRAM socket, write a byte when you want select to return, and don't forget to consume this byte (using recv) when select actually returns.

I thought this was not possible with lwip.
I think this is the way to go.

But, right now, I have something really weird in my system since even with only one thread (using timeout), send() or select() locks when data are received one the cable while other data are transmitted by the application.

Thanks for your help.

Nicolas

HTH,
Yoav.

On 11/01/10 16:24 PM, Nicolas Pinault wrote:


Yoav Nissim a écrit :
Simon,
Is the half duplex limitation only a socket implementation issue? other than the missing locks, what else is missing? using the netconn API seems to result in the same problem.
Isn't the TCPIP thread performing operations one at a time anyway?

Nicolas,
I'm sorry. I tried thinking about this for a while but the only way I could produce any helpful code here is if I throw myself into actually coding and testing it... my boss would not like that I imagine   :)
Ok. I understand. No problem.
Are you working with existing vnc server code that uses two threads, or are you writing the code yourself?
My code is based on a code I have found in eCos svn tree. The original code uses 2 threads. One for receiving commands from client and one for sending screen content.

If you have existing code, maybe you should try serializing the send and receive operations with a separate thread using select as I've suggested earlier.
I have modified my code to use only one thread. The result is catastrophic. It works worse than ever. When trying to transmit, select() terminates with a timeout (1sec)
If you are writing your own code, could you clarify why a single thread (not the main) using select and doing all Rx and Tx would not work?
select() blocks until data are received or timeout occurs.
The system screen is updated by another thread. When the screen has been updated, screen content must be sent to the client.
How do you go out of select() if you don't use timeout ?

Nicolas
Yoav.


On 11/01/10 11:33 AM, Nicolas Pinault wrote:
Simon,

Simon Goldschmidt a écrit :
2. Keep Rx and Tx threads locked and waiting on a select running in
another thread (in essence adding the locking mechanism that lwIP does
not support)
   

The idea is good, but it's not what lwIP doesn't support, since you don't get full duplex but mutual exclusion for read & write. Full duplex would allow simultaneously sending and receiving on the wire. However, that's the best you can get, currently, when using sockets.

 
My problem is not to simultaneously receive and transmit data.
My problem is that I have an application that receives data and transmit data asynchronously.
My application is a vnc server.
Vnc server receives data from client when, for example, the user moves the mouse or hits keys.
Vnc server sends screen content to client when needed.
The client can request the server to force send screen content. In this case, no problem.
But vnc server can also need to send screen content while nothing is received.
Two threads are ideal in this situation. One for receiving commands and one for sending screen content.

I can't see any other solution than using select with a short timeout.

Nicolas

Simon
 


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users

-- 
Yoav Nissim
Software Engineer, Software Tools Division
Jungo Software Technologies
Email: address@hidden
Web: http://www.jungo.com
Phone: +972-74-7212138
Fax: +972-74-7212122
Mobile: +972-54-2271315
------------------------------------------------------------------------

_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________ lwip-users mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/lwip-users

-- 
Yoav Nissim
Software Engineer, Software Tools Division
Jungo Software Technologies
Email: address@hidden
Web: http://www.jungo.com
Phone: +972-74-7212138
Fax: +972-74-7212122
Mobile: +972-54-2271315

_______________________________________________ lwip-users mailing list address@hidden http://lists.nongnu.org/mailman/listinfo/lwip-users

reply via email to

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