- /**
- * Whenever close() is called, OnClose() will be
- * called first. Please note that this means
- * OnClose will be called alongside OnError(),
- * OnTimeout(), and Close().
- */
- virtual void OnClose();
-
- /**
- * Reads all pending bytes from the socket
- * into a char* array which can be up to
- * 16 kilobytes in length.
- */
- virtual const char* Read();
-
- /**
- * Returns the IP address associated with
- * this connection, or an empty string if
- * no IP address exists.
- */
- std::string GetIP();
-
- /**
- * Writes a std::string to the socket. No carriage
- * returns or linefeeds are appended to the string.
- * @param data The data to send
- */
- virtual void Write(const std::string &data);
-
- /**
- * Changes the socket's state. The core uses this
- * to change socket states, and you should not call
- * it directly.
- */
- void SetState(BufferedSocketState s);
-
- /**
- * Call this to receive the next write event
- * that comes along for this fd to the OnWriteReady
- * method.
- */
- void WantWrite();
-
- /**
- * Returns the current socket state.
- */
- BufferedSocketState GetState();
-
- /**
- * Only the core should call this function.
- * When called, it is assumed the socket is ready
- * to read data, and the method call routes the
- * event to the various methods of BufferedSocket
- * for you to handle. This can also cause the
- * socket's state to change.
- */
- bool Poll();
-
- /**
- * This method returns the socket's file descriptor
- * as assigned by the operating system, or -1
- * if no descriptor has been assigned.
- */
- int GetFd();
-
- /**
- * This method causes the socket to close, and may
- * also be triggered by other methods such as OnTimeout
- * and OnError.
- */
- virtual void Close();
-
- /**
- * The destructor may implicitly call OnClose(), and
- * will close() and shutdown() the file descriptor
- * used for this socket.
- */