diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-10 15:52:24 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-09-10 15:52:24 -0700 |
commit | cd3d77987ccaa77df803332a2ab0ff4805fabf70 (patch) | |
tree | 424dcfbc8f5dbae0f4f41e4202fc54c6f48ae641 /osdep | |
parent | a35fa7ac932ff93c9a9a70ff3f57eea5e6a9b19a (diff) | |
download | infinitytier-cd3d77987ccaa77df803332a2ab0ff4805fabf70.tar.gz infinitytier-cd3d77987ccaa77df803332a2ab0ff4805fabf70.zip |
.
Diffstat (limited to 'osdep')
-rw-r--r-- | osdep/Http.cpp | 6 | ||||
-rw-r--r-- | osdep/Phy.hpp | 16 |
2 files changed, 13 insertions, 9 deletions
diff --git a/osdep/Http.cpp b/osdep/Http.cpp index d491b062..0eb7c4c6 100644 --- a/osdep/Http.cpp +++ b/osdep/Http.cpp @@ -68,7 +68,7 @@ struct HttpPhyHandler inline void phyOnTcpConnect(PhySocket *sock,void **uptr,bool success) { if (success) { - phy->tcpSetNotifyWritable(sock,true); + phy->setNotifyWritable(sock,true); } else { *responseBody = "connection failed"; error = true; @@ -92,12 +92,12 @@ struct HttpPhyHandler inline void phyOnTcpWritable(PhySocket *sock,void **uptr) { if (writePtr < writeSize) { - long n = phy->tcpSend(sock,writeBuf + writePtr,writeSize - writePtr,true); + long n = phy->streamSend(sock,writeBuf + writePtr,writeSize - writePtr,true); if (n > 0) writePtr += n; } if (writePtr >= writeSize) - phy->tcpSetNotifyWritable(sock,false); + phy->setNotifyWritable(sock,false); } http_parser parser; diff --git a/osdep/Phy.hpp b/osdep/Phy.hpp index 1a07fa0a..7f790e5d 100644 --- a/osdep/Phy.hpp +++ b/osdep/Phy.hpp @@ -665,19 +665,21 @@ public: } /** - * Attempt to send data to a TCP connection (non-blocking) + * Attempt to send data to a stream socket (non-blocking) * * If -1 is returned, the socket should no longer be used as it is now * destroyed. If callCloseHandler is true, the close handler will be * called before the function returns. * - * @param sock An open TCP socket (other socket types will fail) + * This can be used with TCP, Unix, or socket pair sockets. + * + * @param sock An open stream socket (other socket types will fail) * @param data Data to send * @param len Length of data * @param callCloseHandler If true, call close handler on socket closing failure condition (default: true) * @return Number of bytes actually sent or -1 on fatal error (socket closure) */ - inline long tcpSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true) + inline long streamSend(PhySocket *sock,const void *data,unsigned long len,bool callCloseHandler = true) { PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock)); #if defined(_WIN32) || defined(_WIN64) @@ -755,16 +757,18 @@ public: #endif // __UNIX_LIKE__ /** - * Set whether we want to be notified via the TCP writability handler when a socket is writable + * For streams, sets whether we want to be notified that the socket is writable + * + * This can be used with TCP, Unix, or socket pair sockets. * * Call whack() if this is being done from another thread and you want * it to take effect immediately. Otherwise it is only guaranteed to * take effect on the next poll(). * - * @param sock TCP connection socket (other types are not valid) + * @param sock Stream connection socket * @param notifyWritable Want writable notifications? */ - inline const void tcpSetNotifyWritable(PhySocket *sock,bool notifyWritable) + inline const void setNotifyWritable(PhySocket *sock,bool notifyWritable) { PhySocketImpl &sws = *(reinterpret_cast<PhySocketImpl *>(sock)); if (notifyWritable) { |