- case CONNTYPE_SENDMESSAGE:
- // TODO: Less hack, I need a version of select for GetMessage etc
- if(SysGetMessage(NULL, NULL) == 0) sleep();
- while(SysGetMessage(NULL, NULL))
+ if(nFD <= giConnectionNum)
+ nFD = giConnectionNum+1;
+ FD_SET(giConnectionNum, fds);
+ }
+
+ _SysSelect(nFD, fds, NULL, NULL, NULL, THREAD_EVENT_IPCMSG);
+
+ // Clear out IPC messages
+ while( (len = _SysGetMessage(&tid, 0, NULL)) )
+ {
+ if( giConnectionType != CONNTYPE_SENDMESSAGE || tid != giConnectionNum )
+ {
+ _SysDebug("%i byte message from %i", len, tid);
+ // If not, pass the buck (or ignore)
+ if( gAxWin3_MessageCallback )
+ gAxWin3_MessageCallback(tid, len);
+ else
+ _SysGetMessage(NULL, 0, GETMSG_IGNORE);
+ continue ;
+ }
+
+ // Using CONNTYPE_SENDMESSAGE and server message has arrived
+ ret = malloc(len);
+ if(ret == NULL) {
+ _SysDebug("malloc() failed, ignoring message");
+ _SysGetMessage(NULL, 0, GETMSG_IGNORE);
+ return NULL;
+ }
+ _SysGetMessage(NULL, len, ret);
+ break;
+ }
+
+ if( giConnectionType != CONNTYPE_SENDMESSAGE )
+ {
+ if( FD_ISSET(giConnectionNum, fds) )