[nanomsg] Re: Implementing nanomsg without select or poll functions

  • From: Achille Roussel <achille.roussel@xxxxxxxxx>
  • To: "nanomsg@xxxxxxxxxxxxx" <nanomsg@xxxxxxxxxxxxx>
  • Date: Wed, 6 Aug 2014 08:37:38 -0700

Can't you make the file descriptor non-blocking?
This way accept will fail with EAGAIN if there's nothing to do on the socket.
Otherwise you can set a timeout on the socket (unsure if that affects accept). 

Another way of doing IO multiplexing on posix systems is to use signals, you 
can register for events on file descriptors via the delivery of a signal, this 
is not widely used because it may be harder to get right but that's something 
you may want to look at. Then you replace the call to poll with something like 
sigwaitinfo. 

Achille Roussel
+1 415 490 6339

> On Aug 6, 2014, at 6:50 AM, Moshe Tal <MoTal@xxxxxxxxxxxx> wrote:
> 
> I took the following way to manage this limitation:
> In my poll() function I poll each socket.
> First call to recv() function with MSG_PEEK option (read but don't remove 
> data from the queue) to know if there is any data to get from sockets,.
> Then I call to send() function with 0 length message to know if it is able to 
> send data to the socket.
> 
> My problem is with the accept() function when I can't check the availability 
> of connection in non-intrusive way.
> 
> 
> Moshe Tal-Landau
> Embedded Software Team Leader
> Kramer Electronics
> 
> 
> -----Original Message-----
> From: nanomsg-bounce@xxxxxxxxxxxxx [mailto:nanomsg-bounce@xxxxxxxxxxxxx] On 
> Behalf Of Martin Sustrik
> Sent: Wednesday, August 06, 2014 3:15 PM
> To: nanomsg@xxxxxxxxxxxxx
> Subject: [nanomsg] Re: Implementing nanomsg without select or poll functions
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
>> On 06/08/14 13:16, Moshe Tal wrote:
>> 
>> I need to implement the nanomsg for TCP stack that implement the BSD 
>> socket API partially, it miss either poll() or select() functions.
> 
> They have no way to multiplex among several sockets?
> 
> How can you possibly implement a decent networking application on such 
> platform?
> 
> Maybe they have some proprietary function to do the task?
> 
> Martin
> 
> 
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
> 
> iQEcBAEBAgAGBQJT4hwbAAoJENTpVjxCNN9YAtUIAKUpbjD/hzb2E6MFk0QLFlUx
> 3h1PvbLtQ1wpyyEiuSyvI5KJRxoBYajBJIYz+zAaY95BWXSPiAErW28eh0GNeI+/
> mGDUN8DWvbnvwLk5maWZ4fJ/5cqeQgdKZwQvw9y8O3QmGnSVFalXOXad+ftLA6oy
> s5elNj9+TaGJ6lOYCOCluP0LT2WnhvjlNqA1JpNCfX8ARthA3M7UsFk6MDi8Sx3U
> WO2rsrxzoVEu3DqcCd1Vkwn5t1n2om6sflB3h15Zvtr1xpJlPTqxOXHlvB2Inflb
> rcvuKhIt/CvTg9inKaOARBNkfPBEiaqnXJu+ehh67sAeHlXw9sBYuq6tuu4oxBQ=
> =vHpZ
> -----END PGP SIGNATURE-----
> 
> 
> This mail was sent via Mail-SeCure System.
> 
> 
> 

Other related posts: