当前位置: 首页>>代码示例>>C++>>正文


C++ spl::TCPServer类代码示例

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


在下文中一共展示了TCPServer类的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);
}
开发者ID:romeokienzler,项目名称:MobergStreamsUZH,代码行数:94,代码来源:Data.cpp


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