New build.
This commit is contained in:
1 parent
a5a51f8aae
commit
b4ab5fb86a
835 files changed
+26499
-3119
No files matched your search
@@ -18,12 +18,13 @@ namespace core {
|
||||
/// data threading through use of the EPoll object and also provides buffering for output data
|
||||
/// requests to the socket.
|
||||
///
|
||||
/// A program using a socket object can request to open a socket (file or network or whatever) and
|
||||
/// A program using a socket object can request to open a socket (network or device) and
|
||||
/// communicate through the streambuffer interface of the socket object.
|
||||
///
|
||||
/// The socket side of the Socket accepts EPOLLIN event and will maintain the data in a buffer
|
||||
/// for the stream readers to read. A onDataReceived event is then sent with the data received in
|
||||
/// the buffer that can be read through the stream.
|
||||
/// the buffer that can be read through the stream. Only sockets that send events to epoll can be
|
||||
/// used with this object.
|
||||
///
|
||||
/// When writing to the stream the data is written into a buffer and a EPOLLOUT is scheduled. Upon
|
||||
/// receiving the EPOLLOUT event then the buffer is written to the socket output.
|
||||
@@ -33,8 +34,19 @@ namespace core {
|
||||
|
||||
public:
|
||||
|
||||
Socket(EPoll &ePoll);
|
||||
Socket(EPoll &ePoll, std::string text);
|
||||
///
|
||||
/// Constructor
|
||||
///
|
||||
/// @param ePoll The EPoll socket descriptor.
|
||||
/// @param text A title for this socket.
|
||||
///
|
||||
|
||||
Socket(EPoll &ePoll, std::string text = "");
|
||||
|
||||
///
|
||||
/// Destructor
|
||||
///
|
||||
|
||||
~Socket();
|
||||
|
||||
///
|
||||
@@ -53,15 +65,6 @@ namespace core {
|
||||
void setDescriptor(int descriptor); ///<Set the descriptor for the socket.
|
||||
|
||||
int getDescriptor(); ///< Get the descriptor for the socket.
|
||||
|
||||
class {
|
||||
int value;
|
||||
|
||||
public:
|
||||
int & operator = (const int &i) { return value = i; }
|
||||
operator int () const { return value; }
|
||||
|
||||
} bufferSize; ////> The descriptor to monitor for this socket.
|
||||
|
||||
///
|
||||
/// The event received from epoll is sent through the eventReceived
|
||||
@@ -73,7 +76,7 @@ namespace core {
|
||||
/// simulated.
|
||||
///
|
||||
|
||||
bool eventReceived(struct epoll_event event); ///< Parse epoll event and call specified callbacks.
|
||||
bool eventReceived(struct epoll_event event, pid_t threadId); ///< Parse epoll event and call specified callbacks.
|
||||
|
||||
///
|
||||
/// Write data to the socket.
|
||||
@@ -91,17 +94,19 @@ namespace core {
|
||||
/// descriptor is set using setDescriptor for the socket.
|
||||
///
|
||||
|
||||
virtual void onRegister(); ///< Called when the socket has finished registering with the epoll processing.
|
||||
virtual void onRegistered();
|
||||
virtual void onRegister(); ///< Called before the socket has registered with the epoll processing.
|
||||
virtual void onRegistered(); ///< Called after the socket has been registered with epoll processing.
|
||||
|
||||
virtual void onUnregister();
|
||||
|
||||
///
|
||||
/// The onUnregister method is called whenever the socket is unregistered with
|
||||
/// The onUnregistered method is called whenever the socket is unregistered with
|
||||
/// ePoll and socket communcation events will be stopped. The default method will
|
||||
/// close the socket and clean up the connection. If this is overridden by an
|
||||
/// extended object then the object should call this method to clean the socket up.
|
||||
///
|
||||
|
||||
virtual void onUnregister(); ///< Called when the socket has finished unregistering for the epoll processing.
|
||||
virtual void onUnregistered(); ///< Called when the socket has finished unregistering for the epoll processing.
|
||||
|
||||
bool needsToWrite();
|
||||
|
||||
@@ -110,11 +115,13 @@ namespace core {
|
||||
protected:
|
||||
|
||||
EPoll &ePoll; // The EPoll control object.
|
||||
|
||||
|
||||
bool shutDown = false;
|
||||
|
||||
void setBufferSize(int length);
|
||||
|
||||
|
||||
int getBufferSize();
|
||||
|
||||
///
|
||||
/// The onConnected method is called when the socket is ready to communicate.
|
||||
/// Writing to the socket can begin on this call to initiate a contact with the
|
||||
@@ -153,7 +160,7 @@ namespace core {
|
||||
std::string text;
|
||||
int descriptor = -1;
|
||||
std::mutex lock;
|
||||
std::mutex socketLock;
|
||||
std::mutex outlock;
|
||||
bool readHangup = false;
|
||||
|
||||
// struct epoll_event event; // Event selection construction structure.
|
||||
|
||||
Reference in new issue
Block a user