#include <string.h>
// === CONSTANTS ===
-#define STATICBUF_SIZE 64
+#define STATICBUF_SIZE 256
#define AXWIN_PORT 4101
// === PROTOTYPES ===
void IPC_Init(void);
-void IPC_FillSelect(int *nfds, fd_set *set);
-void IPC_HandleSelect(fd_set *set);
+void IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set);
+void IPC_HandleSelect(fd_set *set, fd_set *err_set);
int IPC_Type_Datagram_GetSize(const void *Ident);
int IPC_Type_Datagram_Compare(const void *Ident1, const void *Ident2);
void IPC_Type_Datagram_Send(const void *Ident, size_t Length, const void *Data);
}
}
-void IPC_FillSelect(int *nfds, fd_set *set)
+void IPC_FillSelect(int *nfds, fd_set *set, fd_set *err_set)
{
_setfd(giNetworkFileHandle, nfds, set);
_setfd(giIPCPipeHandle, nfds, set);
for( int i = 0; i < giIPC_ClientCount; i ++ )
{
- if( gIPC_Clients[i] && gIPC_Clients[i]->IPCType == &gIPC_Type_IPCPipe )
+ if( gIPC_Clients[i] && gIPC_Clients[i]->IPCType == &gIPC_Type_IPCPipe ) {
_setfd( *(int*)(gIPC_Clients[i]->Ident), nfds, set );
+ _setfd( *(int*)(gIPC_Clients[i]->Ident), nfds, err_set );
+ }
}
}
-void IPC_HandleSelect(fd_set *set)
+void IPC_HandleSelect(fd_set *set, fd_set *err_set)
{
if( giNetworkFileHandle != -1 && FD_ISSET(giNetworkFileHandle, set) )
{
}
IPC_Handle( gIPC_Clients[i], len, (void*)staticBuf );
}
+ if( FD_ISSET(fd, err_set) )
+ {
+ // Client disconnected
+ IPC_int_DropClient(gIPC_Clients[i]);
+ _SysClose(fd);
+ }
}
}
}
void IPC_Type_IPCPipe_Send(const void *Ident, size_t Length, const void *Data)
{
- size_t rv = _SysWrite( *(const int*)Ident, Data, Length );
+ int fd = *(const int*)Ident;
+ size_t rv = _SysWrite( fd, Data, Length );
if(rv != Length) {
- _SysDebug("Sent message oversize %x", Length);
+ _SysDebug("Message send for IPCPipe FD %i %i req, %i sent",
+ fd, Length, rv);
}
}