本文整理汇总了C++中spl::TCPServer::setup方法的典型用法代码示例。如果您正苦于以下问题:C++ TCPServer::setup方法的具体用法?C++ TCPServer::setup怎么用?C++ TCPServer::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spl::TCPServer
的用法示例。
在下文中一共展示了TCPServer::setup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conn
void MY_OPERATOR_SCOPE::MY_OPERATOR::process(uint32_t)
{
SPLAPPTRC(L_DEBUG, "TCPSource startup...", SPL_OPER_DBG);
SPL::BeJwrMXQySUksSQQAC4sCC2 tuple$;
try {
SPL::TCPServer conn (getPE());
conn.setup (lit$0);
_fd = conn.fileDescriptor();
SPLAPPTRC(L_DEBUG, "TCPSource connected. File descriptor = " << _fd, SPL_OPER_DBG);
_numConnections.setValueNoLock(1);
while (!getPE().getShutdownRequested()) {
// We might have failed due to handshake failure
if (conn.connected()) {
_tupleNumber = 0;
file_descriptor_source fd_src (_fd, false);
filtering_streambuf<input> filt_str;
filt_str.push (fd_src);
iostream fs (&filt_str);
SPL::StreamByteBuffer sbfs(fs);
fs.imbue(locale::classic());
bool failedRead = false;
while(!getPE().getShutdownRequested() && !fs.eof()) {
_tupleNumber++;
if (SPL::safePeek(fs) == EOF) break;
bool doSubmit = true;
try {
SPL::blob& b = tuple$.get_data();
unsigned rSize;
std::auto_ptr<char>data (new char[lit$1]);
sbfs.getFixedCharSequence(data.get(), lit$1, rSize);
b.adoptData(reinterpret_cast<unsigned char*>(data.release()), rSize);
} catch (const std::exception& e) {
DO_ERROR(SPL_APPLICATION_RUNTIME_EXCEPTION(e.what()));
_numInvalidTuples.incrementValueNoLock();
doSubmit = false;
} catch (...) {
DO_ERROR(SPL_APPLICATION_RUNTIME_UNKNOWN_EXCEPTION);
_numInvalidTuples.incrementValueNoLock();
doSubmit = false;
}
if (doSubmit)
submit (tuple$, 0);
}
submit (Punctuation::WindowMarker, 0);
}
_numConnections.setValueNoLock(0);
_fd = conn.reconnect();
_numConnections.setValueNoLock(1);
_numReconnects.incrementValueNoLock();
}
conn.terminate();
} catch (...) {
// If we get here, we had an exception, and the throw will destruct conn.
// Ensure that we don't try to do it twice.
_fd = 0; // no longer using this
throw;
}
_fd = 0; // no longer using this
SPLAPPTRC(L_DEBUG, "TCPSource exiting...", SPL_OPER_DBG);
}