本文整理汇总了C++中poco::SharedPtr::isConnected方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr::isConnected方法的具体用法?C++ SharedPtr::isConnected怎么用?C++ SharedPtr::isConnected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类poco::SharedPtr
的用法示例。
在下文中一共展示了SharedPtr::isConnected方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("usage: hsWorkServ <Port>\n");
exit(1);
}
int port = atoi(argv[1]);
Poco::Net::SocketAddress socketAddress(Poco::Net::IPAddress(), port);
Poco::Net::DatagramSocket datagramSocket(socketAddress);
MySQL::Connector::registerConnector();
try
{
_pSession = new Session(SessionFactory::instance().create(MySQL::Connector::KEY, _dbConnString));
}catch (ConnectionException& ex)
{
std::cout << "!!! WARNING: Connection failed. MySQL tests will fail !!!" << std::endl;
std::cout << ex.displayText() << std::endl;
exit(1);
}
if (_pSession && _pSession->isConnected())
std::cout << "*** Connected to " << '(' << _dbConnString << ')' << std::endl;
else {
MySQL::Connector::unregisterConnector();
exit(1);
}
char buffer[1024];
while (true)
{
memset(buffer,0x00,sizeof(buffer));
Poco::Net::SocketAddress sender;
int n = datagramSocket.receiveFrom(buffer, sizeof(buffer) - 1, sender);
buffer[n] = '\0';
std::cout << sender.toString() << ": " << buffer << std::endl;
try
{
string sql="";
if(8888 == port)
writeToDB(buffer,sql);
else if(8889 == port)
writeToDB2(buffer,sql);
else
{
std::cout << "Error param" << std::endl;
break;
}
Statement stmt(*_pSession);
stmt << sql;
stmt.execute();
}
catch(ConnectionException& ce){ std::cout << ce.displayText() << std::endl; break; }
catch(StatementException& se){ std::cout << se.displayText() << std::endl; break; }
catch(Exception& e){ std::cout << e.displayText() << std::endl; break; }
}
MySQL::Connector::unregisterConnector();
return 0;
}