Example #1
0
bool	NetworkMoudle::Connect(const char* strIP,int nPort)				// 连接到服务器
{
	m_strIP = strIP;
	m_nServerPort = nPort;
	m_bIsConnect = ConnectToServer(strIP,nPort);
	return m_bIsConnect;
}
Example #2
0
BOOL CTcpClient::Start(LPCTSTR pszRemoteAddress, USHORT usPort, BOOL bAsyncConnect)
{
	if(!CheckParams() || !CheckStarting())
		return FALSE;

	BOOL isOK		= FALSE;
	m_bAsyncConnect	= bAsyncConnect;

	if(CreateClientSocket())
	{
		if(FirePrepareConnect(m_dwConnID, m_soClient) != HR_ERROR)
		{
			if(ConnectToServer(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_FUNCTION_FAILED);
	}
	else
		SetLastError(SE_SOCKET_CREATE, __FUNCTION__, ::WSAGetLastError());

	if(!isOK) Stop();

	return isOK;
}
/*****************************************************************************//**
* @brief This function sets up the PUT response to the remote server after
*    the GET response is returned.
*
* @param status.  The status of the query.
* @param msg.  Result code to be sent back to the remote server.
* @param id.  id of action
* @return nothing.
* @author Neal Shurmantine
* @version
* 02/09/2016    Created.
*******************************************************************************/
uint32_t RAS_SendActionResponse(eActionStatus status, eActionMessageId msg, uint32_t action_id)
{
    REST_CLIENT_QUERY_STRUCT_PTR p_query = (REST_CLIENT_QUERY_STRUCT_PTR)OS_GetMemBlock(sizeof(REST_CLIENT_QUERY_STRUCT));
    char *clientJSON = (char*)OS_GetMemBlock(MAX_JSON_LENGTH);

    LoadDefaultClientData(p_query, &hunterDouglasRASServerSSLParameters,HTTPSRV_REQ_PUT,put_action_response_return);

    snprintf(clientJSON,MAX_JSON_LENGTH, HUB_ACTION_JSON_RESPONSE, status, msg);
    snprintf(p_query->resource,MAX_RESOURCE_NAME_LENGTH, HUB_ACTION_PUT_RESOURCE, RMT_GetAPIVersion(), action_id);

    p_query->json = clientJSON;

    p_query->socket_options.connection_timeout = 18 * SEC_IN_MS;

    MakeAuthorizationString(p_query->authorize,false);

    ConnectToServer(p_query);
    if (p_query->connection.socket) {
        if (PutResource(p_query,false)) {
            p_query->callback(p_query);
        }
        DisconnectFromServer(p_query);
    }
    OS_ReleaseMemBlock((char*)clientJSON);
    OS_ReleaseMemBlock((void*)p_query);
    return 1;
}
void TServerConnectState::Update(nel::TGameTime deltaTime)
{
	TGameState::Update(deltaTime);

	IClient* client = (IClient*)Application->RetrieveInterface(IID_IClient);
	assert(client);
	client->Process();

	switch (progress)
	{
		case SHOULDCONNECT:		
			ConnectToServer();
			progress = CONNECTING;
			break;
		case CONNECTING:	
			if (client->IsConnected()) 
				progress = CONNECTED; 
			break;
		case CONNECTED:
			if (client->IsInLobby())
			{
				progress = INLOBBY;
				Owner->SetNextState(SID_Lobby);
			}
			break;
		case INLOBBY:			
			break;
	};
}
//-----------------------------------------------------------------------------
// Purpose: 
//
//-----------------------------------------------------------------------------
void CUISelectServer::PressOKBtn()
{
	// 서버군과 서버가 선택되었으면 접속 시도.
	int	nSelServerGroup = m_lbServerGroup.GetCurSel();
	int	nSelServer = m_lbServer.GetCurSel();
	if( nSelServerGroup != -1 && nSelServer != -1 )
	{
		sServerInfo &SI = m_vectorGroupInfo[nSelServerGroup].vectorServerInfo[nSelServer];
								
		// 서버에 연결을 시도합니다.
		if( SI.iPlayerNum < _cmiComm.cci_iFullUsers )
		{
			_pSound->Mute();
			if(_pNetwork->m_iServerGroup != m_vectorGroupInfo[nSelServerGroup].iServerNo)
			{
				CUIManager* pUIManager = CUIManager::getSingleton();
				pUIManager->GetRankingViewEx()->ClearRankingList();
			}
			_pNetwork->m_iServerGroup = m_vectorGroupInfo[nSelServerGroup].iServerNo;
			_pNetwork->m_iServerCh = SI.iSubNum;		// UI_REFORM :Su-won

			ConnectToServer( SI.strAddress, SI.iPortNum );

			_pGameState->ClearCharacterSlot();
			
#ifdef RESTRICT_SOUND
			extern BOOL _bNTKernel;
			//if( _bNTKernel )
				_pSound->UpdateSounds();
			#endif
		}
	}
}
int _tmain(int argc, _TCHAR* argv[])
{
    bool isConnected = false;
    do
    {
        std::cout << "Press enter to connect" << std::endl;
        std::cin.get();
        ConnectSocket = ConnectToServer();
        if (ConnectSocket != INVALID_SOCKET)
        {
            std::cout << "Success, begin input" << std::endl;
            isConnected = true;
            DWORD threadId;
            HANDLE tread = CreateThread(
                               NULL,
                               0,
                               ReceiveData,
                               NULL,
                               0,
                               &threadId);
        }
    }
    while (!isConnected);
    while (ConnectSocket != INVALID_SOCKET)
    {
        std::cin.getline(bufferSend, BUFFER_SIZE);
        SendData(ConnectSocket, bufferSend);
    }
    return 0;
}
Example #7
0
BOOL InitCommClient( SOCK *clnt, const char *address, unsigned short serverPortNr, unsigned short clientPortNr, int timeOutMS )
{ BOOL fatal, ret = FALSE;
  int err;
	if( InitIP() && CreateClient( clnt, clientPortNr, TRUE ) ){
		QTils_LogMsgEx( "Client socket opened on port %hu", clientPortNr );
		if( ConnectToServer( *clnt, serverPortNr, "", address, timeOutMS, &fatal ) ){
			QTils_LogMsgEx( "Connected to server \"%s:%hu\"", address, serverPortNr );
			if( !SendMutex ){
				SendMutex = new CritSectEx(4000);
			}
			if( !ReceiveMutex ){
				ReceiveMutex = new CritSectEx(4000);
			}
			ret = TRUE;
		}
		else{
			err = errSock;
			QTils_LogMsgEx( "Failure connecting to server \"%s:%hu\" (err=%d \"%s\")",
						address, serverPortNr, err, errSockText(err) );
			CloseClient(clnt);
		}
	}
	else{
		QTils_LogMsgEx( "Failure opening client socket on port %hu (err=%d \"%s\")",
					clientPortNr, errSock, errSockText(errSock) );
	}
	return ret;
}
Example #8
0
DWORD CMMThread::StartThread(ST_THREADS_PARAM *pstThreadsParam)
{
	ST_THREADS_PARAM stThreadParam = *pstThreadsParam;

	ST_SERVER_ADDR stServerAddr;
	stServerAddr.strIPAddress = stThreadParam.strIPAddress;
	stServerAddr.dwPort = stThreadParam.dwPort;

	InitServerConnection(stServerAddr);

	BOOL bConnected = FALSE;
	BOOL bContinue = TRUE;
	while (bContinue) 
	{
		try
		{
			if (!bConnected) {
				bConnected = ConnectToServer();
			}

			ProcessCycleTask(stThreadParam);
		}
		catch (std::exception &e) {
			ErrorLog("%s", e.what());
			::WSACleanup();
		}

		// Wait for 1 second for a next step
		::Sleep(1000);
	}
	
	::WSACleanup();
	return E_RET_SUCCESS;
}
Example #9
0
VOID WINAPI OnTimerProc(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
{
	switch (idEvent)
	{
		case _ID_TIMER_KEEPALIVE:
		{
			if (g_csock != INVALID_SOCKET)
			{
				SendExToServer(PACKET_KEEPALIVE);
				SendMessage(g_hStatusBar, SB_SETTEXT, MAKEWORD(2, 0), (LPARAM)_TEXT("Check Activity"));
			}

			break;
		}
		case _ID_TIMER_CONNECTSERVER:
		{
			if (g_csock == INVALID_SOCKET)
			{
				DWORD	dwIP = 0;
				int		nPort = 0;

				InsertLogMsg(IDS_APPLY_RECONNECT);

				jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemoteIP"), (LPBYTE)&dwIP);

				if (!jRegGetKey(_SELGATE_SERVER_REGISTRY, _TEXT("RemotePort"), (LPBYTE)&nPort))
					nPort = 5000;

				ConnectToServer(g_csock, &g_caddr, _IDM_CLIENTSOCK_MSG, NULL, dwIP, nPort, FD_CONNECT|FD_READ|FD_CLOSE);
			}

			break;
		}
	}
}
Example #10
0
//---------------------------------------------------------------------------
void __fastcall TSendThread::Execute()
{
	SOCKET ConnectSocket;
	int r;

	User = LoginForm->UserEdit->Text;
	Password = LoginForm->PasswordEdit->Text;

	if (ConnectSocket = ConnectToServer(this,  ms, srv))	{
		if (Auth(this, ConnectSocket))	{
			r = XMLFile(this, ConnectSocket, msXML);
			if (r) {
				SendForm->Close();
				ThreadMsg = "Данные успешно переданы.";
				Synchronize(&ShowThreadMessage);
			}
		}
		ShutDownConnection(this, ConnectSocket);
	}
	if (SendForm->Visible == true) {
		ThreadMsg = "Ошибка при передаче данных. Данные не отправлены.";
		Synchronize(&ShowThreadMessage);
	}

	delete msXML;
//	delete ms;
//    SendForm->Close();
	//---- Place thread code here ----
}
Example #11
0
int PutDoubleData(char *cmdsbuf, short cmds_length, 
				  char *fnamebuf, short fname_length)
{

	int fd, __attribute__ ((unused)) result2;
	char buf[IPCCMDLEN];
	IPCU ipc;

	if( (fd = ConnectToServer()) == -1 )
		return -1;

	// Write "FDATA" command first.
	strcpy(buf, "WDATA");
	result2 = write(fd, buf, IPCCMDLEN);

	// Prepare for ipc union, then copy buffer data.
	ipc.fncmds.cmdslen = (long)cmds_length;
	ipc.fncmds.filenamelen = (long)fname_length;
	memcpy(ipc.fncmds.cmds, cmdsbuf, cmds_length);
	memcpy(ipc.fncmds.filename, fnamebuf, fname_length);
	result2 = write(fd, &ipc, sizeof(IPCU));

	close(fd);
	return 0;
}
Example #12
0
HRESULT CHttpDownloader::WorkFunction()
{
	HRESULT hr;
	_bstr_t strBuffer;
	
	strBuffer = _T("");

	if(m_longAbort > 0)
	{
		hr = E_ABORT;
		goto EndWorkFunc;
	}

	if(m_request.pCritSect)
		EnterCriticalSection(m_request.pCritSect);
	
	if(m_longAbort > 0)
	{
		hr = E_ABORT;
		goto EndWorkFunc;
	}

	hr = ConnectToServer(strBuffer);
	if(FAILED(hr))
		goto EndWorkFunc;

	hr = ReadData(strBuffer);
	if(FAILED(hr) || m_dwDownloaded < m_dwTotalSize)
	{
		strBuffer = _T("Cannot read data");
		goto EndWorkFunc;
	}
	
EndWorkFunc:

//	TRACE(_T("HTTP OPERATION = %d\n"), m_context.op);

	Clear();
	
	if(m_pStream)
	{
		LARGE_INTEGER li = {0, 0};
		hr = m_pStream->Seek(li, STREAM_SEEK_SET, NULL);
	}
	
	if(m_request.pCritSect)
	{
		try
		{
			LeaveCriticalSection(m_request.pCritSect);
		}
		catch(...)
		{
//			MCTRACE(0, _T("LeaveCriticalSection(%08x)"), m_request.pCritSect);
		}
	}
	
	return hr;
}
Example #13
0
cf_void Run()
{
    cf_fd severfd =ServerType::CreateListenSocket(DBPROXYSERVER_PORT);

    std::vector < pthread_t > tids_network;
    pthread_t tid =0;
    // net thread pool.
    for(int i=0; i<g_numPipe; i++)
    {
        int rt =pthread_create(&tid,NULL,ThreadNetwork,(void *)&severfd);
        if(0!=rt)
        {
            printf("pthread_create error,error=%s \n",strerror(errno));
            break;
        }
        tids_network.push_back(tid);
        g_tid_pipe[tid] =i;
    }

    g_inQueue =new TYPE_Queue[g_numPipe];
    g_outQueue =new TYPE_Queue[g_numPipe]; 

    std::vector < pthread_t > tids_dbaccess;
    // db access thread pool.
    for(int i=0; i<g_numPipe*g_threadsCntPerPipe; i++)
    {
        int rt =pthread_create(&tid,NULL,ThreadDBAccess,NULL);
        if(0!=rt)
        {
            printf("pthread_create error,error=%s \n",strerror(errno));
            break;
        }
        tids_dbaccess.push_back(tid);
        ConnectToServer("127.0.0.1",DBPROXYSERVER_PORT);
        g_tid_fd[tid] =-1;
        printf("-- %u->%d g_tid_fd.size()=%u--- \n",(cf_uint32)tid,-1,(cf_uint32)(g_tid_fd.size()));
    }
    
    
    for(int i=0; i<int(tids_network.size()); i++)
    {
        int rt = pthread_join(tids_network[i], NULL);
        if(0!=rt)
        {
            printf("pthread_join error,error=%s \n",strerror(errno));
            break;
        }
    }
    for(int i=0; i<int(tids_dbaccess.size()); i++)
    {
        int rt = pthread_join(tids_dbaccess[i], NULL);
        if(0!=rt)
        {
            printf("pthread_join error,error=%s \n",strerror(errno));
            break;
        }
    }
}
Example #14
0
BOOL JsonServer::MaintainConnection()
{
	if (m_bShutdown) {
		return TRUE;
	}

	if ( m_pLoginServerSession ) {
		if ( m_pLoginServerSession->TryToConnect() ) {
			ConnectToServer( m_pLoginServerSession, (char *)m_pLoginServerSession->GetConnnectIP().c_str(), m_pLoginServerSession->GetConnnectPort() );
		}
	}
	
	if ( m_pDBServerSession ) {
		if ( m_pDBServerSession->TryToConnect() ) {
			ConnectToServer( m_pDBServerSession, (char *)m_pDBServerSession->GetConnnectIP().c_str(), m_pDBServerSession->GetConnnectPort() );
		}
	}
}
Example #15
0
BOOL CDPMonitorClient::Run( LPCSTR lpAddr, u_long uPort, DWORD dwMonitorId, BOOL fsndPing )
{
	if( FALSE == ConnectToServer( lpAddr, uPort, FALSE ) )
		return FALSE;

	BEFORESEND( ar, PACKETTYPE_MONITOR_ID );
	ar << dwMonitorId << fsndPing;
	SEND( ar, this, DPID_SERVERPLAYER );

	return TRUE;
}
void gCommandLineJumpStartAnalyzer::Connect()
{
    tString server;
    tString port;

    ExtractConnectionInformation( _raw, server, port );

    nServerInfoRedirect connectTo( server, port.ToInt() );

    ConnectToServer( &connectTo );
}
Example #17
0
BOOL AutoTest::MaintainConnection()
{
	if (m_bShutdown) {
		return TRUE;
	}
	
	if ( m_pDBServer ) {
		if ( m_pDBServer->TryToConnect() ) {
			ConnectToServer(m_pDBServer);
		}
	}
}
Example #18
0
void KeyboardClicked()
{
	if(gamestate == 0)					//Hotkeys in the "mainmenu"
	{
		if(keyboard->isKeyPressed("ESC") == true)
		{
			play = false;				//Exit the game loop and program
		}
		if(keyboard->isKeyPressed("S") == true || keyboard->isKeyPressed("ENTER") == true)		//Start game
		{
			ConnectToServer();
			gamestate = 1;
		}	
		if(keyboard->isKeyPressed("E") == true)
		{
			play = false;				//Exiting the game loop and program
		}
		if(keyboard->isKeyPressed("ALT") == true && keyboard->isKeyPressed("F4") == true)
		{
			play = false;				//Exiting the program
		}
	}
	else
	{
		if(gamestate == 1)				//We are playing, hotkeys for moving (WASD space enter)
		{
			if(keyboard->isKeyPressed("F10") == true)
			{
				gamestate = 2;			//Viewing menu while playing
			}
		}
		else
		{//We are in game, but the "Menu" (quit/continue) is showing
			if(keyboard->isKeyPressed("C") ==true)
			{
				gamestate  = 1;			//Back to the game, menu is not drawn
			}
			else
			{							//Quit Game, back to main menu
				if(keyboard->isKeyPressed("Q") == true)
				{
					DisconnectFromServer();	
					
					client->Exit();
					gamestate = 0;
					SERVERRESPONSE = false;	

				}
			}
		}
	}
}
//return values:
// 0 - succeed
// 1 - non-block,结果pending,调用者随后需要调用IsSocketWritable来查询结果;
//其它 - 失败
DWORD CTcpClientSocketHelper::Init(DWORD dwIp, DWORD dwPort, WORD wBindLocalPort/*=0*/,
								   BOOL bBlock/*=TRUE*/,DWORD dwConnectTimeOut/*=0*/)
{
	m_dwServerIp = dwIp;
	m_dwServerPort = (WORD)dwPort;
	
	if (!CreateTcpSocket(bBlock))
	{
		return 2;
	}

	return ConnectToServer(wBindLocalPort, dwConnectTimeOut);
}
Example #20
0
void CServerConnect::TryAnotherConnectionRequest()
{
	if (connectionattemps.GetCount() < (thePrefs.IsSafeServerConnectEnabled() ? 1 : 2))
	{
		CServer* next_server = theApp.serverlist->GetNextServer(m_bTryObfuscated);
		if (next_server == NULL)
		{
			if (connectionattemps.GetCount() == 0)
			{
				if (m_bTryObfuscated && !thePrefs.IsClientCryptLayerRequired()){
					// try all servers on the non-obfuscated port next
					m_bTryObfuscated = false;
					ConnectToAnyServer(0, true, true, true);
				}
				else if (m_idRetryTimer == 0)
				{
					// 05-Nov-2003: If we have a very short server list, we could put serious load on those few servers
					// if we start the next connection tries without waiting.
					LogWarning(LOG_STATUSBAR, GetResString(IDS_OUTOFSERVERS));
					AddLogLine(false, GetResString(IDS_RECONNECT), CS_RETRYCONNECTTIME);
					m_uStartAutoConnectPos = 0; // default: start at 0
					VERIFY( (m_idRetryTimer = SetTimer(NULL, 0, 1000*CS_RETRYCONNECTTIME, RetryConnectTimer)) != NULL );
					if (thePrefs.GetVerbose() && !m_idRetryTimer)
						DebugLogError(_T("Failed to create 'server connect retry' timer - %s"), GetErrorMessage(GetLastError()));
				}
			}
			return;
		}

		// Barry - Only auto-connect to static server option
		if (thePrefs.GetAutoConnectToStaticServersOnly())
		{
			if (next_server->IsStaticMember())
                ConnectToServer(next_server, true, !m_bTryObfuscated);
		}
		else
			ConnectToServer(next_server, true, !m_bTryObfuscated);
	}
}
Example #21
0
int CSocketClientTCP::Start(SocketMode mode)
{
    m_bStop=false;
    ConnectToServer();
    if (mode==ReciveOnly || mode==Both)
    {
        recive_pool_prt->schedule(boost::bind(&CSocketClientTCP::ReciveMsg,this));
    }
    if (mode==SendOnly || mode==Both)
    {
        send_pool_prt->schedule(boost::bind(&CSocketClientTCP::SendData,this));
    }
    return 0;
}
Example #22
0
int PutCancel()
{
	int fd, __attribute__ ((unused)) result2;
	char buf[IPCCMDLEN];

	if( (fd = ConnectToServer()) == -1 )
		return -1;

	// Write "CANCEL" command.
	strcpy(buf, "CANCEL");
	result2 = write(fd, buf, IPCCMDLEN);

	close(fd);
	return 0;
}
Example #23
0
bool CLogin::LoginToRealServer(string strServer, int nPort, unsigned int uin)
{
	int nError;

	if ((nError = ConnectToServer(strServer, nPort)) != 0)
		return false;

	SetLoginProgress(40);

	if ((nError = SendLoginInfo(uin)) != 0)
		return false;

	SetLoginProgress(60);
	return true;
}
Example #24
0
bool NetMgr_Android_Impl::ConnectToServer(const char* ip, ushort port)
{
	uint nIP = 0;
	inet_pton(AF_INET, ip, &nIP);
	bool bOk = ConnectToServer(nIP, port);

	if (bOk)
	{
		LOGD("connect to server %s:%d success", ip, port);
	}
	else
	{
		LOGD("connect to server %s:%d failed", ip, port);
	}

	return bOk;
}
Example #25
0
BOOL ClientEngine::OnCmdPickCharAck( UINT16 wCommandID, UINT64 u64ConnID, CBufferHelper *pBufferHelper )
{
	StCharPickCharAck CharPickCharAck;
	pBufferHelper->Read(CharPickCharAck);

	CHECK_PAYER_ID(CharPickCharAck.u64CharID);

	if(CharPickCharAck.nRetCode == E_SUCCESSED)
	{
		DisConnect();
		m_u64ClientID = CharPickCharAck.u64CharID;
		m_dwIdentifyCode = CharPickCharAck.dwIdentifyCode;
		ConnectToServer(CharPickCharAck.szIpAddr, CharPickCharAck.sPort);
	}

	return TRUE;
}
Example #26
0
BOOL CTcpClient::Start(LPCTSTR lpszRemoteAddress, USHORT usPort, BOOL bAsyncConnect, LPCTSTR lpszBindAddress, USHORT usLocalPort)
{
	if(!CheckParams() || !CheckStarting())
		return FALSE;

	PrepareStart();
	m_ccContext.Reset();

	BOOL isOK = FALSE;

	HP_SOCKADDR addrRemote, addrBind;

	if(CreateClientSocket(lpszRemoteAddress, addrRemote, usPort, lpszBindAddress, addrBind))
	{
		if(BindClientSocket(addrBind, addrRemote, usLocalPort))
		{
			if(TRIGGER(FirePrepareConnect(m_soClient)) != HR_ERROR)
			{
				if(ConnectToServer(addrRemote, bAsyncConnect))
				{
					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__, ENSURE_ERROR_CANCELLED);
		}
		else
			SetLastError(SE_SOCKET_BIND, __FUNCTION__, ::WSAGetLastError());
	}
	else
		SetLastError(SE_SOCKET_CREATE, __FUNCTION__, ::WSAGetLastError());

	if(!isOK)
	{
		m_ccContext.Reset(FALSE);
		EXECUTE_RESTORE_ERROR(Stop());
	}

	return isOK;
}
Example #27
0
int PutIPCData(LPIPCU pipc)
{
	int fd, __attribute__ ((unused)) result2;
	char buf[IPCCMDLEN];

	if( (fd = ConnectToServer()) == -1 )
		return -1;

	// Write "PRINT" command first.
	strcpy(buf, "PRINT");
	result2 = write(fd, buf, IPCCMDLEN);

	// And for the time being, simply just write the contents of pipc.
	result2 = write(fd, pipc, sizeof(IPCU));

	close(fd);
	return 0;
}
Example #28
0
int gfc_perform(gfcrequest_t *gfr)
{
	// Connect
	int socketDescriptor = ConnectToServer(gfr->ServerLocation, gfr->Port);

	// Request
	SendRequestToServer(gfr, socketDescriptor);

	// Receive
	ReceiveReponseFromServer(gfr, socketDescriptor);

	close(socketDescriptor);

    gfr->Status = GF_OK;
    gfr->Response.Status = GF_OK;

	return 0;
}
Example #29
0
int ConnectAndSendRequest(mensagem_s * s)
{
	sock = InitConnection();
	int resultado = ConnectToServer(sock);
	if (resultado == -1)
	{
		fprintf(stdout, "Servico nao disponivel de momento, tente mais tarde!\n");
	}
	else
	{
		fprintf(stdout, "Aguarde por favor...\n");
		SendData(sock, s->buffer, s->size + 3);
		RecvData(sock);
		return 1;
	}
	free(s);
	return 0;
}
Example #30
0
	void Framework::Run()
	{
		cout << "starting..." << endl;

		m_tcpClient = new TcpClient();
		m_tcpClient->Start(this, m_ipAddress);
		ConnectToServer();

		// It's all messages to us now.
		cout << "enter \"exit\" to exit program" << endl;
		char line[25];
		while (true)
		{
			cin.getline(line, 25, '\n');
			if (strcmp(line, "exit") == 0)
				break;
		}
	}