Skip to content

Commit

Permalink
Fixed another bug in sending packets
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgammon committed Feb 3, 2017
1 parent ee10978 commit 3607fe1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc.cpp
Expand Up @@ -5744,7 +5744,7 @@ void CMUSHclientDoc::SendPacket (const char * lpBuf, const int nBufLen)
if (m_bDebugIncomingPackets)
Debug_Packets ("Sent ", lpBuf, nBufLen, m_iOutputPacketCount);

m_pSocket->m_outstanding_data += CString (lpBuf, nBufLen);
m_pSocket->m_outstanding_data.append (lpBuf, nBufLen);

m_pSocket->OnSend (0); // in case FD_WRITE message got lost, try to send again

Expand Down
9 changes: 4 additions & 5 deletions worldsock.cpp
Expand Up @@ -43,25 +43,24 @@ int count;
return;

// if we have outstanding data to send, do it

if (m_outstanding_data.GetLength () <= 0)
if (m_outstanding_data.empty ())
return;

count = Send ((LPCTSTR) m_outstanding_data, m_outstanding_data.GetLength ());
count = Send (m_outstanding_data.data (), m_outstanding_data.length ());

if (count != SOCKET_ERROR)
m_pDoc->m_nBytesOut += count; // count bytes out

if (count > 0) // good send - do rest later
m_outstanding_data = m_outstanding_data.Mid (count);
m_outstanding_data.erase (0, count);
else
{
int nError = GetLastError ();
if (count == SOCKET_ERROR && nError != WSAEWOULDBLOCK)
{
ShutDownSocket (*this);
// m_pSocket->OnClose (nError); // ????
m_outstanding_data.Empty ();
m_outstanding_data.erase ();

} // end of an error other than "would block"
} // end of an error
Expand Down
2 changes: 1 addition & 1 deletion worldsock.h
Expand Up @@ -26,7 +26,7 @@ class CWorldSocket : public CAsyncSocket
// Operations
public:
CMUSHclientDoc* m_pDoc;
CString m_outstanding_data;
string m_outstanding_data;

// Implementation

Expand Down

0 comments on commit 3607fe1

Please sign in to comment.