summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/SocketThreads.h
diff options
context:
space:
mode:
authordaniel0916 <theschokolps@gmail.com>2014-04-07 20:12:17 +0200
committerdaniel0916 <theschokolps@gmail.com>2014-04-07 20:12:17 +0200
commit2e9754ac1cf0537c12ab7974cf55c451c0724540 (patch)
tree713c5b8c8f22f77893b30b9c8cefca4a7c491483 /src/OSSupport/SocketThreads.h
parentFixed merge conflict (diff)
parentFixed some more minor issues with the redstone simulator. (diff)
downloadcuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.gz
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.bz2
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.lz
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.xz
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.tar.zst
cuberite-2e9754ac1cf0537c12ab7974cf55c451c0724540.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/SocketThreads.h30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/OSSupport/SocketThreads.h b/src/OSSupport/SocketThreads.h
index 9e1947ab6..679e374e1 100644
--- a/src/OSSupport/SocketThreads.h
+++ b/src/OSSupport/SocketThreads.h
@@ -64,9 +64,10 @@ public:
virtual ~cCallback() {}
/** Called when data is received from the remote party */
- virtual void DataReceived(const char * a_Data, int a_Size) = 0;
+ virtual void DataReceived(const char * a_Data, size_t a_Size) = 0;
- /** Called when data can be sent to remote party; the function is supposed to *append* outgoing data to a_Data */
+ /** Called when data can be sent to remote party
+ The function is supposed to *set* outgoing data to a_Data (overwrite) */
virtual void GetOutgoingData(AString & a_Data) = 0;
/** Called when the socket has been closed for any reason */
@@ -102,7 +103,7 @@ private:
public:
cSocketThread(cSocketThreads * a_Parent);
- ~cSocketThread();
+ virtual ~cSocketThread();
// All these methods assume parent's m_CS is locked
bool HasEmptySlot(void) const {return m_NumSlots < MAX_SLOTS; }
@@ -156,16 +157,27 @@ private:
virtual void Execute(void) override;
- /** Puts all sockets into the set, along with m_ControlSocket1.
- Only sockets that are able to send and receive data are put in the Set.
- Is a_IsForWriting is true, the ssWritingRestOut sockets are added as well. */
- void PrepareSet(fd_set * a_Set, cSocket::xSocket & a_Highest, bool a_IsForWriting);
+ /** Prepares the Read and Write socket sets for select()
+ Puts all sockets into the read set, along with m_ControlSocket1.
+ Only sockets that have outgoing data queued on them are put in the write set.*/
+ void PrepareSets(fd_set * a_ReadSet, fd_set * a_WriteSet, cSocket::xSocket & a_Highest);
- void ReadFromSockets(fd_set * a_Read); // Reads from sockets indicated in a_Read
- void WriteToSockets (fd_set * a_Write); // Writes to sockets indicated in a_Write
+ /** Reads from sockets indicated in a_Read */
+ void ReadFromSockets(fd_set * a_Read);
+ /** Writes to sockets indicated in a_Write */
+ void WriteToSockets (fd_set * a_Write);
+
+ /** Sends data through the specified socket, trying to fill the OS send buffer in chunks.
+ Returns true if there was no error while sending, false if an error has occured.
+ Modifies a_Data to contain only the unsent data. */
+ bool SendDataThroughSocket(cSocket & a_Socket, AString & a_Data);
+
/** Removes those slots in ssShuttingDown2 state, sets those with ssShuttingDown state to ssShuttingDown2 */
void CleanUpShutSockets(void);
+
+ /** Calls each client's callback to retrieve outgoing data for that client. */
+ void QueueOutgoingData(void);
} ;
typedef std::list<cSocketThread *> cSocketThreadList;