Skip to content

Commit 14f63be

Browse files
committed
Trying to fix problem with missing incoming data
1 parent cc3867a commit 14f63be

File tree

3 files changed

+23
-11
lines changed

3 files changed

+23
-11
lines changed

doc.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,11 +1162,6 @@ CString str;
11621162
return TRUE;
11631163
}
11641164

1165-
void CMUSHclientDoc::ProcessPendingRead()
1166-
{
1167-
ReceiveMsg();
1168-
}
1169-
11701165
// SendMsg sends a message (command) to the MUD.
11711166
// If there is already a queue (for speedwalking etc.) it is placed
11721167
// at the end of the queue. The message is marked to indicate whether
@@ -1350,15 +1345,18 @@ CString str = strText;
13501345

13511346
}
13521347

1353-
void CMUSHclientDoc::ReceiveMsg()
1348+
void CMUSHclientDoc::ReceiveMsg(char * buff, int count)
13541349
{
1355-
char buff [1000]; // must be less than COMPRESS_BUFFER_LENGTH or it won't fit
1356-
int count = m_pSocket->Receive (buff, sizeof (buff) - 1);
13571350

13581351
Frame.CheckTimerFallback (); // see if time is up for timers to fire
13591352

13601353
if (count == SOCKET_ERROR)
13611354
{
1355+
1356+
DWORD errcode = GetLastError();
1357+
if (errcode == WSAEWOULDBLOCK || errcode == 0)
1358+
return; // it's ok, nothing to do
1359+
13621360
// don't delete the socket if we are already closing it
13631361
if (m_iConnectPhase == eConnectDisconnecting)
13641362
return;

doc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,15 +1399,14 @@ class CMUSHclientDoc : public CDocument
13991399
// Operations
14001400
public:
14011401
BOOL ConnectSocket(void);
1402-
void ProcessPendingRead();
14031402
void DoSendMsg(const CString& strText,
14041403
const bool bEchoIt,
14051404
const bool bLogIt);
14061405
void SendMsg(CString strText,
14071406
const bool bEchoIt,
14081407
const bool bQueueIt,
14091408
const bool bLogIt);
1410-
void ReceiveMsg();
1409+
void ReceiveMsg(char * buff, int count);
14111410
void DisplayMsg(LPCTSTR lpszText, int size, const int flags);
14121411
void AddToLine (LPCTSTR lpszText, const int flags);
14131412
void StartNewLine_KeepPreviousStyle (const int flags);

worldsock.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,22 @@ CWorldSocket::CWorldSocket(CMUSHclientDoc* pDoc)
2929

3030
void CWorldSocket::OnReceive(int nErrorCode)
3131
{
32-
m_pDoc->ProcessPendingRead();
32+
33+
char buff [1000]; // must be less than COMPRESS_BUFFER_LENGTH or it won't fit
34+
35+
while (true)
36+
{
37+
int count = m_pDoc->m_pSocket->Receive (buff, sizeof (buff) - 1);
38+
m_pDoc->ReceiveMsg(buff, count);
39+
40+
if (count == 0) // connection closed or nothing left
41+
break;
42+
43+
if (count == SOCKET_ERROR)
44+
break; // some error or other
45+
46+
} // end of while
47+
3348
CAsyncSocket::OnReceive(nErrorCode);
3449
}
3550

0 commit comments

Comments
 (0)