本文整理汇总了C++中IsConnected函数的典型用法代码示例。如果您正苦于以下问题:C++ IsConnected函数的具体用法?C++ IsConnected怎么用?C++ IsConnected使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了IsConnected函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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 ();
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
}
示例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 );
}
示例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);
}
示例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);
}
示例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;;
}
示例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();
}
示例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;
}