|
CPN
Computational Process Networks
|
#include <ServerSocketHandle.h>
Inheritance diagram for ServerSocketHandle:
Collaboration diagram for ServerSocketHandle:Public Types | |
| typedef AutoLock< PthreadMutex > | ALock |
Public Member Functions | |
| ServerSocketHandle () | |
| ServerSocketHandle (int nfd) | |
| ServerSocketHandle (const SocketAddress &addr, int queuelength=256) | |
| ServerSocketHandle (const SockAddrList &addrs, int queuelength=256) | |
| void | Listen (const SocketAddress &addr, int queuelength=256) |
| void | Listen (const SockAddrList &addrs, int queuelength=256) |
| int | Accept (SocketAddress &addr) |
| int | Accept () |
| void | SetReuseAddr (bool reuse=true) |
| Turn on reuse of the address. Only takes effect if set before Listen. More... | |
| bool | GetReuseAddr () |
| int | Poll (double timeout) |
| bool | Readable (bool r) |
| Set that the file is currently readable or not. More... | |
| bool | Readable () const |
| Gives the current readability status of the file. More... | |
| bool | Writeable (bool w) |
| Set that this file is currently writeable or not. More... | |
| bool | Writeable () const |
| Gives the current writability status of the file. More... | |
| int | FD () const |
| int | FD (int filed) |
| Set the current file descriptor. More... | |
| bool | Eof () const |
| bool | Eof (bool e) |
| Set/reset the end of file condition. More... | |
| bool | Good () const |
| Convenience method for testing if the file this FileHandle has is open and not at end of file. More... | |
| bool | Closed () const |
| void | SetBlocking (bool blocking) |
| Manipulate how the current file handles blocking. More... | |
| bool | IsBlocking () const |
| Test if the current file is in blocking or non blocking mode. More... | |
| void | Reset () |
| Clear all internal state including the file descriptor! WARNING does not close the file! More... | |
| void | Close () |
| Close the file and reset the internal state. More... | |
| unsigned | Read (void *ptr, unsigned len) |
| Read data from the file descriptor. More... | |
| unsigned | Readv (const iovec *iov, int iovcnt) |
| scatter gather io version of Read More... | |
| unsigned | Write (const void *ptr, unsigned len) |
| Write data to the file descriptor. More... | |
| unsigned | Writev (const iovec *iov, int iovcnt) |
| scatter gather io version of Write More... | |
| void | Flush () |
| Tell the OS to flush any buffers it has. May not be supported for all file types. More... | |
Static Public Member Functions | |
| static int | Poll (IteratorRef< FileHandle * > begin, IteratorRef< FileHandle * > end, double timeout) |
| poll a list of FileHandles for any activity and call the appropriate On method. More... | |
| static void | SetBlocking (int fd, bool blocking) |
| a convenience method that allows one to set the same blocking parameters for a file descriptor without setting it inside a FileHandle. More... | |
| static bool | IsBlocking (int fd) |
| Test the given file descriptor if it is in blocking mode. More... | |
Protected Member Functions | |
| virtual void | OnReadable () |
| Called by Poll when it detects that the file is readable. More... | |
| virtual void | OnWriteable () |
| Called by Poll when it detects that the file is writeable. More... | |
Protected Attributes | |
| PthreadMutex | file_lock |
| int | fd |
| bool | readable |
| bool | writeable |
| bool | eof |
Private Member Functions | |
| bool | Listen (const SocketAddress &addr, int queuelength, int &error) |
| int | Accept (SocketAddress *addr) |
Private Attributes | |
| bool | reuse_addr |
Provides functionality for a server socket in a FileHandle
Definition at line 33 of file ServerSocketHandle.h.
|
inherited |
Definition at line 43 of file FileHandle.h.
|
inline |
Definition at line 36 of file ServerSocketHandle.h.
|
inline |
Definition at line 37 of file ServerSocketHandle.h.
|
inline |
Definition at line 38 of file ServerSocketHandle.h.
References Listen().
Here is the call graph for this function:
|
inline |
Definition at line 40 of file ServerSocketHandle.h.
References Listen().
Here is the call graph for this function:| int ServerSocketHandle::Accept | ( | SocketAddress & | addr | ) |
Accept an incoming connection.
| addr | a SocketAddress object to fill with the address of the connecting peer. |
| ErrnoException | for errors |
Definition at line 46 of file ServerSocketHandle.cc.
References Accept().
Referenced by CPN::ConnectionServer::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:| int ServerSocketHandle::Accept | ( | ) |
Accept an incoming connection
Definition at line 50 of file ServerSocketHandle.cc.
Referenced by Accept(), and CPN::RemoteContextDaemon::Read().
Here is the caller graph for this function:
|
private |
Definition at line 53 of file ServerSocketHandle.cc.
References FileHandle::FD(), SocketAddress::GetAddr(), SocketAddress::GetLen(), and FileHandle::Readable().
Here is the call graph for this function:
|
inherited |
Close the file and reset the internal state.
Definition at line 146 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::readable, and FileHandle::writeable.
Referenced by CPN::ConnectionServer::Close(), CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::HandleError(), CPN::RemoteQueue::InternalCheckStatus(), and CPN::RemoteContextDaemon::Terminate().
Here is the caller graph for this function:
|
inlineinherited |
Definition at line 128 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
Referenced by SocketHandle::Connect(), CPN::ConnectionServer::ConnectReader(), CPN::ConnectionServer::ConnectWriter(), CPN::RemoteQueue::FileThreadEntryPoint(), CPN::RemoteQueue::InternalCheckStatus(), CPN::RemoteQueue::LogState(), CPN::ConnectionServer::LogState(), CPN::RemoteContextDaemon::Run(), CPN::RemoteContextDaemon::Client::Send(), and CPN::RemoteContext::SendMessage().
Here is the caller graph for this function:
|
inlineinherited |
Definition at line 115 of file FileHandle.h.
References FileHandle::eof, and FileHandle::file_lock.
Referenced by CPN::RemoteQueue::EnqueuePacket(), CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::InternalCheckStatus(), CPN::RemoteContextDaemon::Client::Read(), and CPN::RemoteQueue::Read().
Here is the caller graph for this function:Set/reset the end of file condition.
| e | the new end of file condition |
Definition at line 120 of file FileHandle.h.
References FileHandle::eof, and FileHandle::file_lock.
|
inlineinherited |
Definition at line 106 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
Referenced by Accept(), CPN::RemoteContextDaemon::Client::Client(), SocketHandle::Connect(), CPN::ConnectionServer::ConnectWriter(), SocketHandle::CreatePair(), CPN::RemoteQueue::FileThreadEntryPoint(), FileHandle::Flush(), CPN::ConnectionServer::GetAddress(), SocketHandle::GetKeepAlive(), SocketHandle::GetLingerTimeout(), SocketHandle::GetNoDelay(), SocketHandle::GetPendingError(), SocketHandle::GetReceiveBufferSize(), SocketHandle::GetReceiveTimeout(), SocketHandle::GetSendBufferSize(), SocketHandle::GetSendTimeout(), FileHandle::IsBlocking(), Listen(), FileHandle::Poll(), CPN::RemoteContextDaemon::Run(), FileHandle::SetBlocking(), SocketHandle::SetKeepAlive(), SocketHandle::SetLingerTimeout(), SocketHandle::SetNoDelay(), SocketHandle::SetReceiveBufferSize(), SocketHandle::SetReceiveTimeout(), SocketHandle::SetSendBufferSize(), SocketHandle::SetSendTimeout(), SocketHandle::ShutdownRead(), SocketHandle::ShutdownWrite(), and WakeupHandle::WakeupHandle().
Here is the caller graph for this function:Set the current file descriptor.
| filed | the new file descriptor |
Definition at line 111 of file FileHandle.h.
References FileHandle::fd, and FileHandle::file_lock.
|
inherited |
Tell the OS to flush any buffers it has. May not be supported for all file types.
Definition at line 293 of file FileHandle.cc.
References FileHandle::FD().
Here is the call graph for this function:
|
inline |
|
inlineinherited |
Convenience method for testing if the file this FileHandle has is open and not at end of file.
Definition at line 125 of file FileHandle.h.
References FileHandle::eof, FileHandle::fd, and FileHandle::file_lock.
Referenced by CPN::RemoteContext::EntryPoint(), and CPN::RemoteContextDaemon::Client::Read().
Here is the caller graph for this function:
|
inherited |
Test if the current file is in blocking or non blocking mode.
Definition at line 128 of file FileHandle.cc.
References FileHandle::FD().
Here is the call graph for this function:Test the given file descriptor if it is in blocking mode.
| fd | the file descriptor to test |
Definition at line 132 of file FileHandle.cc.
| void ServerSocketHandle::Listen | ( | const SocketAddress & | addr, |
| int | queuelength = 256 |
||
| ) |
Open a new socket and try to listen on the given SocketAddress.
Definition at line 30 of file ServerSocketHandle.cc.
Referenced by CPN::ConnectionServer::ConnectionServer(), Listen(), CPN::RemoteContextDaemon::RemoteContextDaemon(), and ServerSocketHandle().
Here is the caller graph for this function:| void ServerSocketHandle::Listen | ( | const SockAddrList & | addrs, |
| int | queuelength = 256 |
||
| ) |
Open a new socket and try to listen on one of the addresses in the given list.
Definition at line 35 of file ServerSocketHandle.cc.
References Listen().
Here is the call graph for this function:
|
private |
Definition at line 103 of file ServerSocketHandle.cc.
References SocketAddress::Family(), FileHandle::FD(), SocketAddress::GetAddr(), SocketAddress::GetLen(), and reuse_addr.
Here is the call graph for this function:
|
inlineprotectedvirtualinherited |
Called by Poll when it detects that the file is readable.
Reimplemented in WakeupHandle.
Definition at line 210 of file FileHandle.h.
References FileHandle::Readable().
Referenced by FileHandle::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inlineprotectedvirtualinherited |
Called by Poll when it detects that the file is writeable.
Definition at line 212 of file FileHandle.h.
References FileHandle::Writeable().
Referenced by FileHandle::Poll().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticinherited |
poll a list of FileHandles for any activity and call the appropriate On method.
Definition at line 34 of file FileHandle.cc.
References FileHandle::FD(), FileHandle::fd, FileHandle::OnReadable(), FileHandle::OnWriteable(), FileHandle::Readable(), and FileHandle::Writeable().
Referenced by CPN::RemoteContext::EntryPoint(), CPN::RemoteQueue::FileThreadEntryPoint(), CPN::ConnectionServer::Poll(), FileHandle::Poll(), and CPN::RemoteContextDaemon::Run().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Poll the current file descriptor for activity specified by the current readable or writeable status, if false poll that value, and call one of OnWriteable or OnReadable whos default action is to set Readable or Writeable to true.
| timeout | -1 to wait forever for activity 0 to poll and return immediately or a time to wait in seconds. |
Definition at line 106 of file FileHandle.cc.
References FileHandle::Poll().
Here is the call graph for this function:
|
inherited |
Read data from the file descriptor.
Will set the end of file condition if read detects end of file.
| ptr | pointer to write data to |
| len | the maximum number of bytes to write to ptr |
Definition at line 159 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::Readable(), and FileHandle::readable.
Referenced by CPN::RemoteQueue::D4RTagPacket(), and WakeupHandle::Read().
Here is the call graph for this function:
Here is the caller graph for this function:Set that the file is currently readable or not.
| r | true or false |
Definition at line 86 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::readable.
Referenced by CPN::RemoteContext::EntryPoint(), FileHandle::Poll(), CPN::ConnectionServer::Poll(), and CPN::RemoteQueue::Read().
Here is the caller graph for this function:
|
inlineinherited |
Gives the current readability status of the file.
Definition at line 91 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::readable.
Referenced by Accept(), CPN::RemoteContextDaemon::Client::Client(), FileHandle::OnReadable(), CPN::RemoteContextDaemon::Read(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), CPN::RemoteContextDaemon::Run(), and WakeupHandle::WakeupHandle().
Here is the caller graph for this function:
|
inherited |
scatter gather io version of Read
Definition at line 190 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::Readable(), and FileHandle::readable.
Referenced by CPN::RemoteQueue::EnqueuePacket().
Here is the call graph for this function:
Here is the caller graph for this function:
|
inherited |
Clear all internal state including the file descriptor! WARNING does not close the file!
Definition at line 138 of file FileHandle.cc.
References FileHandle::eof, FileHandle::fd, FileHandle::file_lock, FileHandle::readable, and FileHandle::writeable.
Referenced by CPN::ConnectionServer::ConnectWriter(), CPN::RemoteQueue::FileThreadEntryPoint(), and FileHandle::~FileHandle().
Here is the caller graph for this function:
|
inherited |
Manipulate how the current file handles blocking.
| blocking | true to set to blocking mode (default) false to set to non blocking mode. |
In non blocking mode all reads and writes will not block. Use Poll to block.
Definition at line 111 of file FileHandle.cc.
References FileHandle::FD().
Referenced by WakeupHandle::WakeupHandle().
Here is the call graph for this function:
Here is the caller graph for this function:a convenience method that allows one to set the same blocking parameters for a file descriptor without setting it inside a FileHandle.
| fd | the file descriptor |
| blocking | true or false see SetBlock |
Definition at line 115 of file FileHandle.cc.
|
inline |
Turn on reuse of the address. Only takes effect if set before Listen.
Definition at line 70 of file ServerSocketHandle.h.
References reuse_addr.
Referenced by CPN::RemoteContextDaemon::RemoteContextDaemon().
Here is the caller graph for this function:
|
inherited |
Write data to the file descriptor.
| ptr | pointer to beginning of data to write |
| len | length of data to write |
Definition at line 225 of file FileHandle.cc.
References FileHandle::fd, FileHandle::file_lock, and FileHandle::Writeable().
Referenced by CPN::ConnectionServer::ConnectWriter(), CPN::RemoteContextDaemon::Client::Send(), CPN::RemoteContext::SendMessage(), and CPN::RemoteQueue::WriteBytes().
Here is the call graph for this function:
Here is the caller graph for this function:Set that this file is currently writeable or not.
| w | true or false |
Definition at line 97 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::writeable.
Referenced by FileHandle::Poll().
Here is the caller graph for this function:
|
inlineinherited |
Gives the current writability status of the file.
Definition at line 102 of file FileHandle.h.
References FileHandle::file_lock, and FileHandle::writeable.
Referenced by FileHandle::OnWriteable(), SocketHandle::Send(), WakeupHandle::WakeupHandle(), FileHandle::Write(), and FileHandle::Writev().
Here is the caller graph for this function:
|
inherited |
scatter gather io version of Write
Definition at line 261 of file FileHandle.cc.
References FileHandle::fd, FileHandle::file_lock, and FileHandle::Writeable().
Referenced by CPN::RemoteQueue::WriteBytes().
Here is the call graph for this function:
Here is the caller graph for this function:
|
protectedinherited |
Definition at line 217 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Eof(), FileHandle::Good(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), and FileHandle::Reset().
|
protectedinherited |
Definition at line 214 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Closed(), FileHandle::FD(), FileHandle::Good(), FileHandle::Poll(), FileHandle::Read(), FileHandle::Readv(), SocketHandle::Recv(), FileHandle::Reset(), SocketHandle::Send(), FileHandle::Write(), FileHandle::Writev(), and FileHandle::~FileHandle().
|
mutableprotectedinherited |
Definition at line 213 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Closed(), FileHandle::Eof(), FileHandle::FD(), FileHandle::Good(), FileHandle::Read(), FileHandle::Readable(), FileHandle::Readv(), SocketHandle::Recv(), FileHandle::Reset(), SocketHandle::Send(), WakeupHandle::SendWakeup(), FileHandle::Write(), FileHandle::Writeable(), and FileHandle::Writev().
|
protectedinherited |
Definition at line 215 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Read(), FileHandle::Readable(), FileHandle::Readv(), SocketHandle::Recv(), and FileHandle::Reset().
|
private |
Definition at line 75 of file ServerSocketHandle.h.
Referenced by GetReuseAddr(), Listen(), and SetReuseAddr().
|
protectedinherited |
Definition at line 216 of file FileHandle.h.
Referenced by FileHandle::Close(), FileHandle::Reset(), and FileHandle::Writeable().
1.8.5