-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 03/17/2014 02:25 PM, Joe Love wrote: > So, treating it like a tcp socket was working well when trying to > wait for a query response. However, during an asynchronous > connection, libpq will cycle between reading & writing, while > calling PQconnectPoll(..). > > Is there a way (using the tcp series of functions) to wait until a > socket is writable, and issue a callback at that point in time? > > The best I can find for that, is to actually try writing to it with > an empty buffer, and use the callback there to do the next > operation. > > OR, I can look at using uv_poll* which appears to have the ability > to detect if a socket is readable or writable at a point in time. > Since I don't actually need to read or write to the socket > directly, is there any particular reason to avoid using the uv_poll > series of functions, since all I need to do is have a callback > execute when a socket ready for reading or writing? Efficiency, > perhaps? >
I think you are better off using uv_poll_t handles. If the library (postgres in this case) fiddles with the fd, it could enter an inconsistent state, might be closed without you knowing, for example. On unices uv_poll_t is a thin wrapper on top of epoll/kequeue/devports and on Windows it uses some black magic you probably don't want to know about :-P So, you should be fine using uv_poll_t. As an example, Node uses uv_poll_t to integrate with c-ares. Cheers, - -- Saúl Ibarra Corretgé bettercallsaghul.com -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iQIcBAEBAgAGBQJTJv0eAAoJEEEOVVOum8BZWtwP/3hl9qhJu82MmMTcpWkkarO2 b7csr/Ho6GxnahtoImKV59imtCF5eFQo5Kh/7GI519b5kQWRcFRz5N8Egn+CTzG7 CpxmT1Y02yC7tuSg5B2oWZ7SVmOB1UP1a1y8+BXm6v3/T41ijer2ZyHqE1IP33lQ MhWsdofuplzZtaXsFa7bJoFgbUI02QyojDF8W0397HY1MaAUwENWmpwX7YiKV6/x DXeXq7ZBV47jAb7HIQeUhQXEDMbCyyBfH/mEH4+UTNLi1lvjzE/QMD9H+11wS4bR 7MWaTj7+YDf8QgIugKMFTP/S0/xPifXaiOjEnKz57Kt8tJLAXI8deuIneQSaxk8m 0Og9x7XTEIXD0hYYjXRUBCwLaPPGFS3cyiFwnRPUO3zTk/PT4QhwkN4YBiRdjhTX C208veMgABuqZe6lOlRhzuZ86DFx6CoPdbwvLUDLHzpcz3RpVioNi0QlVUj99PWa 3AYpBarRMkYVw1l0Ri7eIkkbrIJoXKq1iGhsNIkuGM5oqUO6c81r2Nnsvl02+KJb CdYVTNZQcZ4bL5jMZDQJ6MI0TtgZCkxKXa9jto7zIuPNXLGu8Xqkk5kmXlTnCeSC JUko0/yIgpPdgSOaf/+RZBGx6W5iWL2uhR6pxLBfh1cpVhx11/oqbHoFW/OXGXAX Fdp4SNM2yI9qjl9ti+rZ =Zovz -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "libuv" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/libuv. For more options, visit https://groups.google.com/d/optout.
