• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ IsConnected函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中IsConnected函数的典型用法代码示例。如果您正苦于以下问题:C++ IsConnected函数的具体用法?C++ IsConnected怎么用?C++ IsConnected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了IsConnected函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: PostSend

bool ClientSession::PostSend()
{
	if ( !IsConnected() )
	{
		return false;
	}
		

	FastSpinlockGuard criticalSection(mBufferLock);
	
	if ( 0 == mBuffer.GetContiguiousBytes() )
	{
		return true;
	}
		

	OverlappedSendContext* sendContext = new OverlappedSendContext(this);

	DWORD sendbytes = 0;
	DWORD flags = 0;
	sendContext->mWsaBuf.len = (ULONG) mBuffer.GetContiguiousBytes(); 
	sendContext->mWsaBuf.buf = mBuffer.GetBufferStart();

	/// start async send
	if (SOCKET_ERROR == WSASend(mSocket, &sendContext->mWsaBuf, 1, &sendbytes, flags, (LPWSAOVERLAPPED)sendContext, NULL))
	{
		if (WSAGetLastError() != WSA_IO_PENDING)
		{
			DeleteIoContext(sendContext);
			printf_s("ClientSession::PostSend Error : %d\n", GetLastError());

			return false;
		}
			
	}

	return true;
}
开发者ID:flashscope,项目名称:14-2-game_server_hw,代码行数:38,代码来源:ClientSession.cpp


示例2: MakeDir

int CFileZillaApi::MakeDir(const CServerPath &path)
{
	//Check if call allowed
	if (!m_bInitialized)
		return FZ_REPLY_NOTINITIALIZED;
	if (IsConnected()==FZ_REPLY_NOTCONNECTED)
		return FZ_REPLY_NOTCONNECTED;
	if (IsBusy()==FZ_REPLY_BUSY)
		return FZ_REPLY_BUSY;
	if (path.IsEmpty() || !path.HasParent())
		return FZ_REPLY_INVALIDPARAM;

	t_command command;
	command.id=FZ_COMMAND_MAKEDIR;
	command.path=path;
	m_pMainThread->Command(command);
	if (m_hOwnerWnd)
		return FZ_REPLY_WOULDBLOCK;
	else
		return m_pMainThread->LastOperationSuccessful()?FZ_REPLY_OK:FZ_REPLY_ERROR;
	
	return FZ_REPLY_ERROR;
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:23,代码来源:FileZillaApi.cpp


示例3: UpdateNetwork

void CNetworkModule::Pulse( void )
{
	// Is the game not loaded?
	if( !pCore->IsGameLoaded() )
		return;

	// Are we disconnected from the network?
	if( GetNetworkState() == NETSTATE_DISCONNECTED )
		return;

	// Process the network
	UpdateNetwork ();

	// Are we connected?
	if( IsConnected() )
	{
		// Pulse the player manager
		pCore->GetPlayerManager()->Pulse ();

		// Pulse the vehicle manager
		pCore->GetVehicleManager()->Pulse ();
	}
}
开发者ID:WD32,项目名称:maf2mp,代码行数:23,代码来源:CNetworkModule.cpp


示例4: Chmod

int CFileZillaApi::Chmod(int nValue, CString FileName, const CServerPath &path /*=CServerPath()*/ )
{
	//Check if call allowed
	if (!m_bInitialized)
		return FZ_REPLY_NOTINITIALIZED;
	if (IsConnected()==FZ_REPLY_NOTCONNECTED)
		return FZ_REPLY_NOTCONNECTED;
	if (IsBusy()==FZ_REPLY_BUSY)
		return FZ_REPLY_BUSY;
	if (FileName==_MPT(""))
		return FZ_REPLY_INVALIDPARAM;

	t_command command;
	command.id=FZ_COMMAND_CHMOD;
	command.param1=FileName;
	command.param4=nValue;
	command.path=path;
	m_pMainThread->Command(command);
	if (m_hOwnerWnd)
		return FZ_REPLY_WOULDBLOCK;
	else
		return m_pMainThread->LastOperationSuccessful()?FZ_REPLY_OK:FZ_REPLY_ERROR;
}
开发者ID:CyberShadow,项目名称:Far-NetBox,代码行数:23,代码来源:FileZillaApi.cpp


示例5: Disconnect

void CNeighbour::Disconnect()
{
	if ( ! IsConnected() ) return;

	m_bConnected = FALSE;
	
	StopThread();
	
	DisconnectNamedPipe( m_hPipe );
	m_hPipe		= INVALID_HANDLE_VALUE;
	
	for ( POSITION pos = m_pList.GetStartPosition(); pos; )
	{
		CString xUserId;
		CCircuitry* pChannel;
		
		m_pList.GetNextAssoc( pos, xUserId, (void*&)pChannel );
		
		if ( pChannel ) pChannel->Release();
	}
	
	m_pList.RemoveAll();
}
开发者ID:pics860,项目名称:callcenter,代码行数:23,代码来源:Neighbour.cpp


示例6: fprintf

int P4ClientAPI::Disconnect()
{
	if ( P4LUADEBUG_COMMANDS )
		fprintf( stderr, "[P4] Disconnect\n" );

    if ( ! IsConnected() )
	{
//		rb_warn( "P4:disconnect - not connected" );
		return 0;
	}

	Error	e;
	client.Final( &e );
    ResetFlags();

	// Clear the specdef cache.
	specMgr.Reset();

    // Clear out any results from the last command
    ui.Reset();

	return 0;
}
开发者ID:scw000000,项目名称:Engine,代码行数:23,代码来源:p4clientapi.cpp


示例7: Connect

bool MySQLInterface::Connect(const char *host,
							 const char *user,
							 const char *passwd,
							 const char *db,
							 unsigned int port,
							 const char *unix_socket,
							 unsigned long clientflag)
{
	if (IsConnected())
		return false;

	_host=host;
	_user=user;
	_passwd=passwd;
	_db=db;
	_port=port;
	_unix_socket=unix_socket;
	_clientflag=clientflag;


	mySqlConnection = mysql_init(0);
	return mysql_real_connect (mySqlConnection, host, user, passwd, db, port, unix_socket, clientflag) != 0;
}
开发者ID:AbdulRehmanDaud,项目名称:RakNet,代码行数:23,代码来源:MySQLInterface.cpp


示例8: GoOffline

bool
BeNetWindow::QuitRequested(void)
{

	// Save the preferences
	Preferences::Instance()->Save();

	// Go offline
	if (TClient::Instance()->IsOnline())
		GoOffline();

	if (IsConnected())
		Disconnect();

	// Delete the recorder (pretend that it's recording)
	if (m_pRecorder != NULL) {        // OliverESP: we have to look out the pointer!
		m_pRecorder->StopRecording();
		delete m_pRecorder;
		m_pRecorder = NULL;
	}
	be_app_messenger.SendMessage(B_QUIT_REQUESTED);
	return true;
}
开发者ID:BackupTheBerlios,项目名称:dengon-svn,代码行数:23,代码来源:BeNetWindow.cpp


示例9: Select

ByteArray ConnectorMySQL::Select(const ByteArray &command, ErrorCode &error_code)
{
	if (IsConnected())
	{
		mysql_real_query(&mysql_, command.data(), command.size());
		int error = mysql_errno(&mysql_);
		if (error != 0)
		{
			error_code.SetError(error, mysql_error(&mysql_));
			return ByteArray();
		}

		ByteArray bytes;
		MYSQL_RES *sql_result = mysql_store_result(&mysql_);
		mysql_stuff::Serialize(sql_result, &bytes);
		mysql_free_result(sql_result);
		return bytes;
	}
	else
	{
		throw NotConnected();
	}
}
开发者ID:afa311,项目名称:eddyserver,代码行数:23,代码来源:ConnectorMySQL.cpp


示例10: QueryAvailableDatabases_Async

	/**
	 * Initiates asynchronous query for available task databases
	 *
	 * @param	InServerName		Server host name
	 * @param	InServerPort		Server port
	 * @param	InLoginUserName		User name
	 * @param	InLoginPassword		Password
	 *
	 * @return	True if async requested was kicked off successfully
	 */
	bool QueryAvailableDatabases_Async( const FString& InServerName, const uint32 InServerPort, const FString& InLoginUserName, const FString& InLoginPassword )
	{
		if( IsConnected() )
		{
			TDLOG( TEXT( "Async request failed because we're already connected to a server" ) );
			return false;
		}

		// Build a server URL string (e.g. "http://myservername:80")
		FString ServerURL =
			FString( TEXT( "http://" ) ) +
			InServerName +
			FString( TEXT( ":" ) ) +
			FString( FString::FromInt( InServerPort ) );

		FTaskDatabaseRequest_QueryAvailableDatabases* Request = new FTaskDatabaseRequest_QueryAvailableDatabases();
		Request->RequestType = ETaskDatabaseRequestType::QueryAvailableDatabases;
		Request->ServerURL = ServerURL;
		Request->LoginUserName = InLoginUserName;
		Request->LoginPassword = InLoginPassword;

		return StartAsyncRequest( Request );
	}
开发者ID:1vanK,项目名称:AHRUnrealEngine,代码行数:33,代码来源:TaskDatabase.cpp


示例11: printf

Server::~Server(){
    printf("Closing Server.\n");

    lock();
    network_task->should_die = true;
    
    if(IsConnected())
        Thread::RemoveSocketFromTaskGroup(state.socket, Thread::GetShortThreadPool());

    while(!task_died){
        unlock();

        lock();
    }
    unlock();

    // Not particularly concerned with whether this fails or not.
    // There's not a lot we can do if it fails.
    Disconnect_Socket(state.socket);
    Destroy_Socket(state.socket);


}
开发者ID:FlyingJester,项目名称:Kashyyyk,代码行数:23,代码来源:server.cpp


示例12: Connect

bool 
MemCacheClient::Server::Connect(
    int a_nTimeout
    ) 
{
    // already connected? do nothing
    if (IsConnected()) {
        return true;
    }

    // only try to re-connect to a broken server occasionally
    time_t nNow;
#ifdef WIN32
    nNow = GetTickCount();
    if (nNow - mLastConnect < MEMCACHECLIENT_RECONNECT_SEC * 1000) return false;
#else
    time(&nNow);
    if (nNow - mLastConnect < MEMCACHECLIENT_RECONNECT_SEC) return false;
#endif
    mLastConnect = nNow;
    
    return ServerSocket::Connect(mIp, mPort, a_nTimeout);
}
开发者ID:dalinhuang,项目名称:loosoft,代码行数:23,代码来源:MemCacheClient.cpp


示例13: TableExists

bool Postgres::TableExists(const wxString& sTableName)
  {
  if(!IsConnected())
    throw wx::Exception(wxT("Postgres::TableExists() Database not connected."));

  wxString sqryTableExists = wxT("            \
SELECT                                        \
  cl.relname                                  \
FROM                                          \
  pg_class cl                                 \
INNER JOIN                                    \
  pg_namespace ns                             \
ON                                            \
  cl.relnamespace = ns.oid                    \
WHERE                                         \
  ns.nspname = 'public'                       \
AND                                           \
  cl.reltype <> 0                             \
AND                                           \
  cl.relkind = 'r'                            \
AND                                           \
  cl.relname = $1;                            \
");

  ArrayRecord arParams;
  arParams.push_back(wxVariant(sTableName));
  ArrayRecordArray ara;
  stc.CacheExecute
    (
    wxT("Postgres::TableExists"),
    sqryTableExists,
    arParams,
    ara
    );

  return (ara.size() != 0)? true : false;;
  }
开发者ID:joeyates,项目名称:sherpa,代码行数:37,代码来源:postgres.cpp


示例14: GetTables

wxArrayString Postgres::GetTables()
  {
  if(!IsConnected())
    throw wx::Exception(wxT("Postgres::GetTables() Database not connected."));

  wxString sqryTables = wxT("                 \
SELECT                                        \
  relname                                     \
FROM                                          \
  pg_class cl                                 \
INNER JOIN                                    \
  pg_namespace ns                             \
ON                                            \
  cl.relnamespace = ns.oid                    \
WHERE                                         \
  ns.nspname = 'public'                       \
AND                                           \
  cl.reltype <> 0                             \
AND                                           \
  cl.relkind = 'r';                           \
");

  ArrayRecordArray ara;
  stc.CacheExecute
    (
    wxT("Postgres::GetTables"),
    sqryTables,
    ArrayRecord(),
    ara
    );

  ArrayRecord ar;
  for(ArrayRecordArray::iterator it = ara.begin(); it != ara.end(); it++)
    ar.push_back(it->at(0));

  return ar.GetArrayString();
  }
开发者ID:joeyates,项目名称:sherpa,代码行数:37,代码来源:postgres.cpp


示例15: _OutPacket

OUTPACKET_RESULT WorldServerSocket::_OutPacket(uint16 opcode, size_t len, const void* data)
{
	bool rv;
	if(!IsConnected())
		return OUTPACKET_RESULT_NOT_CONNECTED;

	BurstBegin();
	//if((m_writeByteCount + len + 4) >= m_writeBufferSize)
	if( GetWriteBuffer().GetSpace() < (len+4) )
	{
		BurstEnd();
		return OUTPACKET_RESULT_NO_ROOM_IN_BUFFER;
	}

	// Packet logger :)
	sWorldLog.LogPacket((uint32)len, opcode, (const uint8*)data, 1);
	// Encrypt the packet
	// First, create the header.
	ServerPktHeader Header;
	Header.cmd = opcode;
	Header.size = ntohs((uint16)len + 2);

    _crypt.EncryptFourSend((uint8*)&Header);

	// Pass the header to our send buffer
	rv = BurstSend((const uint8*)&Header, 4);

	// Pass the rest of the packet to our send buffer (if there is any)
	if(len > 0 && rv)
	{
		rv = BurstSend((const uint8*)data, (uint32)len);
	}

	if(rv) BurstPush();
	BurstEnd();
	return rv ? OUTPACKET_RESULT_SUCCESS : OUTPACKET_RESULT_SOCKET_ERROR;
}
开发者ID:DeaDSandro,项目名称:shadowfade,代码行数:37,代码来源:WorldServerSocket.cpp


示例16: MOZ_ASSERT

uint32_t
NamedPipeInfo::Peek(void* aBuffer, int32_t aSize)
{
  MOZ_ASSERT(PR_GetCurrentThread() == gSocketThread);
  MOZ_ASSERT(mReadBegin <= mReadEnd);

  if (!IsConnected()) {
    // pipe unconnected
    PR_SetError(PR_NOT_CONNECTED_ERROR, 0);
    return -1;
  }

  /**
   * If there's nothing in the read buffer, try to trigger internal read
   * operation by calling |GetPollFlags|. This is required for callers that
   * use blocking I/O because they don't call |GetPollFlags| to read data,
   * but this also works for non-blocking I/O.
   */
  if (!Available()) {
    int16_t outFlag;
    GetPollFlags(PR_POLL_READ, &outFlag);

    if (!(outFlag & PR_POLL_READ)) {
      PR_SetError(IsNonblocking() ? PR_WOULD_BLOCK_ERROR
                                  : PR_IO_PENDING_ERROR,
                  0);
      return -1;
    }
  }

  // Available() can't return more than what fits to the buffer at the read offset.
  int32_t bytesRead = std::min<int32_t>(aSize, Available());
  MOZ_ASSERT(bytesRead >= 0);
  MOZ_ASSERT(mReadBegin + bytesRead <= mReadEnd);
  memcpy(aBuffer, &mReadBuffer[mReadBegin], bytesRead);
  return bytesRead;
}
开发者ID:mephisto41,项目名称:gecko-dev,代码行数:37,代码来源:nsNamedPipeIOLayer.cpp


示例17: switch

bool IrcBot::SendData(MessageType type, char const* data)
{
    std::stringstream ss;

    switch(type)
    {
        case USER:
            ss << "USER " << IRC_USER_NICK << " 0 * :" << data;
            break;
        case NICK:
            ss << "NICK " << data;
            break;
        case IDENTIFY:
            ss << "PRIVMSG NickServ :IDENTIFY " << data;
            break;
        case JOIN:
            ss << "JOIN " << data;
            break;
        case PRIVMSG:
            ss << "PRIVMSG " << IRC_CHANNEL << " :" << data;
            break;
        default:
            ss << data;
            break;
    }

    if (IsConnected())
    {
        std::string temp = ss.str();
        temp += "\r\n";
        char const* message = temp.c_str();
        if (send(_socket, message, strlen(message), 0) == -1)
            return false;
    }

    return true;
}
开发者ID:sk3tche,项目名称:TrinityCore,代码行数:37,代码来源:IRC.cpp


示例18: SideOfPier

PierSide ScopeINDI::SideOfPier(void)
{
    PierSide pierSide = PIER_SIDE_UNKNOWN;
    
    try
    {
        if (!IsConnected())
        {
            throw ERROR_INFO("INDI Scope: cannot get side of pier when not connected");
        }
        
        if (pierside_prop == NULL)
        {
            throw THROW_INFO("INDI Scope: not capable of getting side of pier");
        }
        else
        {
            if (piersideEast_prop->s == ISS_ON) {
                pierSide = PIER_SIDE_EAST;
                
            }
            if (piersideWest_prop->s == ISS_ON) {
                pierSide = PIER_SIDE_WEST;
                
            }
        }
    }
    
    catch (const wxString& Msg)
    {
        POSSIBLY_UNUSED(Msg);
    }
    
    Debug.Write(wxString::Format("ScopeINDI::SideOfPier() returns %d\n", pierSide));
    
    return pierSide;
}
开发者ID:AndresPozo,项目名称:phd2,代码行数:37,代码来源:scope_INDI.cpp


示例19: GetGuidingDeclination

// Special purpose function to return the guiding declination (radians) - either the actual scope position or the
// default values defined in mount.cpp.  Doesn't throw exceptions to callers.
double ScopeASCOM::GetGuidingDeclination(void)
{
    double dReturn = Scope::GetDefGuidingDeclination();

    try
    {
        if (!IsConnected())
        {
            throw ERROR_INFO("ASCOM Scope: cannot get Declination when not connected to mount");
        }

        if (!m_bCanGetCoordinates)
        {
            throw THROW_INFO("!m_bCanGetCoordinates");
        }

        GITObjRef scope(m_gitEntry);

        Variant vRes;
        if (!scope.GetProp(&vRes, dispid_declination))
        {
            throw ERROR_INFO("GetDeclination() fails: " + ExcepMsg(scope.Excep()));
        }

        dReturn = radians(vRes.dblVal);
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        m_bCanGetCoordinates = false;
    }

    Debug.AddLine("ScopeASCOM::GetDeclination() returns %.1f", degrees(dReturn));

    return dReturn;
}
开发者ID:rwg0,项目名称:phd2,代码行数:38,代码来源:scope_ascom.cpp


示例20: Connect

sBool sTCPClientSocket::Connect(sIPAddress address, sIPPort port)
{
  TransferError=0;

  if (IsConnected()) Disconnect();

  sNET_SOCKTYPE s=socket(PF_INET,SOCK_STREAM,0);

  if (s==sINVALID_SOCKET)
  {
    P->HandleError();
    return sFALSE;
  }

  sClear(P->Address);
  P->Address.sin_family=AF_INET;
  P->Address.sin_port=htons(port);
  sCopyMem(&P->Address.sin_addr,&address,4);

  sInt res=connect(s,(sockaddr*)&P->Address,sizeof(P->Address));

  if (!res)
  {
    P->Socket=s;
    P->Connected=sTRUE;
    return sTRUE;
  }

  int namelen = sizeof(P->LocalAddress);
  getsockname(s,(sockaddr*)&P->LocalAddress,&namelen);

  P->HandleError();
  closesocket(s);

  return sFALSE;
}
开发者ID:loCurnus,项目名称:werkkzeug4CE,代码行数:36,代码来源:sockets_bsd.cpp



注:本文中的IsConnected函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ IsConnectionIdle函数代码示例发布时间:2022-05-30
下一篇:
C++ IsComplete函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap