void ArduinoThread::NewConnection() { sock = serv->nextPendingConnection(); if(!sock) return; connect(sock, SIGNAL(disconnected()), this, SLOT(Disconnected())); emit SocketConnected(); }
void CTCPSocketAsync::SystemTimeout() { //Call socket timeout SocketConnected(teConnectionTimeout); }
BOOL CTCPSocketAsync::LocalConnect(unsigned short usSourcePort, IP aDestinationAddress, unsigned short usDestinationPort, BOOL bDisableAsync, BOOL bForceErrorEvent) { try { //Quit if not ok if (!CheckSocketValid()) return FALSE; //Set the async notification if (!bDisableAsync) { int iResult; iResult=InternalWSAAsyncSelect(WM_SOCKET_CONNECT, FD_CONNECT); if (iResult) { //Get the error code int iErrorCode; iErrorCode=GetSystemLastError(); //Report it SetLastError("Connect"); //Do we need to call event? if (bForceErrorEvent) SocketConnected(iErrorCode); //Exit return FALSE; } //Set our timeout if (m_ulTimeout && !IsBlocking()) if (!SetSystemTimeout(m_ulTimeout)) { //Report it ReportError("LocalConnect","Failed to set timer!"); //Do we need to call event? if (bForceErrorEvent) SocketConnected(GetErrorCode()); //Exit return FALSE; } } //Set to non blocking! else if (!Block()) return FALSE; //Set the flag m_bDisabledConnect=bDisableAsync; //Call the original connect BOOL bResult; bResult=CTCPSocket::Connect(usSourcePort, aDestinationAddress, usDestinationPort); //Reset the flag m_bDisabledConnect=FALSE; if (bResult) { //Call event, but only if in async if (!bDisableAsync && !IsBlocking()) //Call user, will add socket automatically return SocketConnected(0); else //Set as async return SetAsync(); } else if (GetSystemLastError()!=WSAEWOULDBLOCK || bDisableAsync || IsBlocking()) { if (m_ulTimeout) //Kill the timer KillSystemTimer(); //Get the error code int iErrorCode; iErrorCode=GetSystemLastError(); //Report it SetLastError("Connect"); //Do we need to call event? if (bForceErrorEvent && !bDisableAsync) SocketConnected(iErrorCode); //Exit return FALSE; } else return TRUE; } ERROR_HANDLER_RETURN("LocalConnect",FALSE) }
void MessageHandler::HandleConnected() { connect(socket_, SIGNAL(readyRead()), this, SLOT(ReadMessage())); SocketConnected(); // Emits this signal }