21 #ifndef CO_CONNECTION_H 22 #define CO_CONNECTION_H 27 #include <lunchbox/bitOperation.h> 28 #include <lunchbox/referenced.h> 29 #include <boost/noncopyable.hpp> 31 #include <sys/types.h> 37 namespace detail {
class Connection; }
56 class Connection :
public lunchbox::Referenced,
public boost::noncopyable
83 CO_API
State getState()
const;
86 bool isClosed()
const {
return getState() == STATE_CLOSED; }
89 bool isClosing()
const {
return getState() == STATE_CLOSING; }
92 bool isConnected()
const {
return getState() == STATE_CONNECTED; }
95 bool isListening()
const {
return getState() == STATE_LISTENING; }
98 CO_API
bool isMulticast()
const;
104 bool operator == (
const Connection& rhs )
const;
140 void addListener( ConnectionListener* listener );
143 void removeListener( ConnectionListener* listener );
186 CO_API
void recvNB( BufferPtr buffer,
const uint64_t bytes );
203 CO_API
bool recvSync( BufferPtr& buffer,
const bool block =
true );
205 BufferPtr resetRecvData();
225 CO_API
bool send(
const void* buffer,
const uint64_t bytes,
226 const bool isLocked =
false );
229 CO_API
void lockSend()
const;
232 CO_API
void unlockSend()
const;
235 virtual void finish() {}
248 virtual Notifier getNotifier()
const = 0;
280 virtual void readNB(
void* buffer,
const uint64_t bytes ) = 0;
294 virtual int64_t readSync(
void* buffer,
const uint64_t bytes,
295 const bool block ) = 0;
307 virtual int64_t write(
const void* buffer,
const uint64_t bytes ) = 0;
315 CO_API
void _setState(
const State state );
322 detail::Connection*
const _impl;
325 CO_API std::ostream& operator << ( std::ostream&,
const Connection& );
334 #endif //CO_CONNECTION_H State
The current state of the Connection.
Defines export visibility macros for library Collage.
lunchbox::RefPtr< ConnectionDescription > ConnectionDescriptionPtr
A reference pointer for ConnectionDescription pointers.
The connection has been connected and is open.
The connection is listening for connects.
A connect() or listen() is in progress.
virtual ConnectionPtr acceptSync()
Complete an accept operation.
int Notifier
The Notifier used by the ConnectionSet to detect readiness of a Connection.
Object-oriented network library.
virtual void close()
Close a connected or listening connection.
virtual bool connect()
Connect to the remote peer.
virtual bool listen()
Put the connection into the listening state.
virtual void acceptNB()
Start an accept operation.
An interface definition for communication between hosts.
ReadStatus
< error codes for readSync()
lunchbox::RefPtr< const ConnectionDescription > ConstConnectionDescriptionPtr
A reference pointer for const ConnectionDescription pointers.
lunchbox::RefPtr< Connection > ConnectionPtr
A reference pointer for Connection pointers.