BOOL CUdpCast::Start(LPCTSTR pszRemoteAddress, USHORT usPort, BOOL bAsyncConnect) { if(!CheckParams() || !CheckStarting()) return FALSE; BOOL isOK = FALSE; if(CreateClientSocket()) { if(FirePrepareConnect(this, m_soClient) != HR_ERROR) { if(ConnectToGroup(pszRemoteAddress, usPort)) { if(CreateWorkerThread()) { isOK = TRUE; } else SetLastError(SE_WORKER_THREAD_CREATE, __FUNCTION__, ERROR_CREATE_FAILED); } else SetLastError(SE_CONNECT_SERVER, __FUNCTION__, ::WSAGetLastError()); } else SetLastError(SE_SOCKET_PREPARE, __FUNCTION__, ERROR_CANCELLED); } else SetLastError(SE_SOCKET_CREATE, __FUNCTION__, ::WSAGetLastError()); if(!isOK) Stop(); return isOK; }
BOOL CUdpCast::Start(LPCTSTR lpszRemoteAddress, USHORT usPort, BOOL bAsyncConnect, LPCTSTR lpszBindAddress) { if(!CheckParams() || !CheckStarting()) return FALSE; PrepareStart(); m_ccContext.Reset(); BOOL isOK = FALSE; HP_SOCKADDR bindAddr(AF_UNSPEC, TRUE); if(CreateClientSocket(lpszRemoteAddress, usPort, lpszBindAddress, bindAddr)) { if(BindClientSocket(bindAddr)) { if(FirePrepareConnect(m_soClient) != HR_ERROR) { if(ConnectToGroup(bindAddr)) { if(CreateWorkerThread()) { isOK = TRUE; } else SetLastError(SE_WORKER_THREAD_CREATE, __FUNCTION__, ERROR_CREATE_FAILED); } else SetLastError(SE_CONNECT_SERVER, __FUNCTION__, ::WSAGetLastError()); } else SetLastError(SE_SOCKET_PREPARE, __FUNCTION__, ERROR_CANCELLED); } else SetLastError(SE_SOCKET_BIND, __FUNCTION__, ::WSAGetLastError()); } else SetLastError(SE_SOCKET_CREATE, __FUNCTION__, ::WSAGetLastError()); if(!isOK) { DWORD dwCode = ::GetLastError(); m_ccContext.Reset(FALSE); Stop(); ::SetLastError(dwCode); } return isOK; }