Ejemplo n.º 1
0
//-----------------------------------------------------------------------
// Send state message to all active connections
// return TRUE if message was send to at least one client
//-----------------------------------------------------------------------
BOOL Ros_StateServer_SendMsgToAllClient(Controller* controller, SimpleMsg* sendMsg, int msgSize)
{
	int index;
	int ret;
	BOOL bHasConnections = FALSE;
	
	// Check all active connections
	for(index = 0; index < MAX_STATE_CONNECTIONS; index++)
	{
		if(controller->sdStateConnections[index] != INVALID_SOCKET)
		{
			ret = mpSend(controller->sdStateConnections[index], (char*)(sendMsg), msgSize, 0);
			if(ret <= 0)
			{
				printf("StateServer Send failure.  Closing state server connection.\r\n");
				mpClose(controller->sdStateConnections[index]);
				controller->sdStateConnections[index] = INVALID_SOCKET;
			}
			else
			{
				bHasConnections = TRUE;
			}
		}
	}
	return bHasConnections;
}
Ejemplo n.º 2
0
static int sendN(int handle, char *buf, int n, int flags) {
    int lastSend = -1;
    int totalSend = 0;
    do {
        lastSend = mpSend(handle, (buf + totalSend), n - totalSend, flags);
        if (lastSend < 1) {
            fprintf(stderr, "tcpSvr: send error : %s\n", strerror(errno));
            return lastSend;
        }
        totalSend += lastSend;
    } while (totalSend < n);
    return totalSend;
}