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


C++ TCP类代码示例

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


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

示例1: l_hasflags

/***
 * Check if the TCP Layer has the given flag combination
 * @function hasflags
 * @tparam num flags a flag mask
 * @treturn num r 0 if the layer doesn't have the flags
 * @usage tcp:hasflags(TCP.SYN + TCP.ACK)
 */
int l_tcp_ref::l_hasflags(lua_State *l)
{
	TCP *tcp = l_tcp_ref::get(l, 1);
	int flags = l_data_type<int>::get(l, 2);
	l_data_type<int>(tcp->GetFlags() & flags).push(l);
	return 1;
}
开发者ID:matttbe,项目名称:tracebox,代码行数:14,代码来源:lua_tcp.cpp

示例2: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
	
	TCP* tcp = new TCP();

	try
	{
		char chain[2104];
		string separtor = "";

		cout << "Input a chain of a numbers separated by spaces: ";
		cin.getline(chain, sizeof(chain));

		cout << "Input a separator: ";
		cin >> separtor;


		Send(tcp, chain);

		Send(tcp, separtor, false);

		cout << "Reseive: " << endl;
		cout << tcp->ReceiveData() << endl;
		tcp->CloseConnection();
	}
	catch (string error)
	{
		cout << error;
		tcp->CloseConnection();
	}
}
开发者ID:codeserfer,项目名称:7-term,代码行数:31,代码来源:2+-+client.cpp

示例3: if

bool Signature::quirkPast( const Packet &p ) const
{
    //Checks for options after EOL

    bool eol = false;

    if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) )
    {
        IPv4 ip = p.getInet<IPv4>( 0 );
        TCP tcp = p.getTrans<TCP>( 0 );
        std::vector< SmartPtr< TCPOption > > options = tcp.options();

        for( int i = 0; i < options.size(); ++i )
        {
            TCPOption * opt = options[i];

            if( !eol && opt->kind() == TCPOption::END_OF_LIST )
            {
                eol = true;
            }
            else if( eol && opt->kind() != TCPOption::END_OF_LIST )
            {
                return true;
            }
        }
    }
    return false;
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:28,代码来源:signatures.cpp

示例4: setDontFragment

void Signature::setFromPacket( const Packet &p )
{
    if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) )
    {
        IPv4 ip = p.getInet<IPv4>( 0 );
        TCP tcp = p.getTrans<TCP>( 0 );
        std::vector< SmartPtr< TCPOption > > options = tcp.options();
        uint32_t quirks = 0;

        //set IP stuff
        setDontFragment( ip.dontFragment() );
        setTtl( ip.ttl() );
        //set TCP stuff
        setWindowSize( tcp.windowSize() );

        //set TCP options
        std::vector< uint8_t > tcpOptions;
        std::vector< SmartPtr< TCPOption > >::iterator itr;
        for( itr = options.begin(); itr != options.end(); ++itr )
        {
            uint8_t kind = (*itr)->kind();
            if( kind == TCPOption::MAXIMUM_SEGMENT_SIZE )
            {
                MSSOption* mss = static_cast<MSSOption*>((*itr).data());
                mss_ = mss->mss();
            }
            checkForQuirks( p );
            tcpOptions.push_back( kind );
        }
        setTcpOptions( tcpOptions );
    }
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:32,代码来源:signatures.cpp

示例5: quirkUrg

bool Signature::quirkUrg( const Packet &p ) const
{
    if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) )
    {
        TCP tcp = p.getTrans<TCP>( 0 );
        return tcp.URG_Flag();
    }
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:8,代码来源:signatures.cpp

示例6: TEST_F

TEST_F(TCPTest, Flags) {
    TCP tcp;
    tcp.set_flag(TCP::SYN, 1);
    tcp.set_flag(TCP::FIN, 1);
    
    EXPECT_EQ(tcp.flags(), (TCP::SYN | TCP::FIN));
    tcp.flags(TCP::PSH | TCP::RST);
    EXPECT_EQ(tcp.flags(), (TCP::PSH | TCP::RST));
}
开发者ID:Temptationx,项目名称:libtins,代码行数:9,代码来源:tcp.cpp

示例7: quirkFlags

bool Signature::quirkFlags( const Packet &p ) const
{
    if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) )
    {
        TCP tcp = p.getTrans<TCP>( 0 );
        if( tcp.URG_Flag() || tcp.PSH_Flag() )
            return true;
    }
    return false;
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:10,代码来源:signatures.cpp

示例8: quirkAck

bool Signature::quirkAck( const Packet &p ) const
{
    if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) )
    {
        TCP tcp = p.getTrans<TCP>( 0 );
        if( tcp.acknowledgementNumber() != 0 )
            return true;
    }
    return false;
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:10,代码来源:signatures.cpp

示例9:

bool Signature::quirkX2( const Packet &p ) const
{
    if( p.inetIs< IPv4 >( 0 ) && p.transIs< TCP >( 0 ) )
    {
        TCP tcp = p.getTrans<TCP>( 0 );
        if( tcp.x2() != 0 )
            return true;
    }
    return false;
}
开发者ID:MuminSalimov,项目名称:packet-manipulation-library,代码行数:10,代码来源:signatures.cpp

示例10: accept_client

    TCP TCP::accept_client (void) {
        TCP ret;
        socklen_t len = sizeof (struct sockaddr_in);

        ret.close();
        ret._socket_id = accept (this->_socket_id, (struct sockaddr*) &ret._address, &len);
        ret._opened = true;
        ret._binded = true;

        return ret;
    }
开发者ID:wangchenxicool,项目名称:my_arp,代码行数:11,代码来源:TCP.cpp

示例11: host_

/*
	This is most likely used in a PASSIVE open
*/
Connection::Connection(TCP& host, Port local_port) :
	host_(host),
	local_port_(local_port), 
	remote_(TCP::Socket()),
	state_(&Connection::Closed::instance()),
	prev_state_(state_),
	control_block(),
	receive_buffer_(host.buffer_limit()),
	send_buffer_(host.buffer_limit()),
	time_wait_started(0)
{
	
}
开发者ID:doniexun,项目名称:IncludeOS,代码行数:16,代码来源:tcp_connection.cpp

示例12: main

int main()
{
  TCP myTCP;
  myTCP.set_zero();
  myTCP.getip();
  myTCP.print_parameters();
  myTCP.create_data();
  myTCP.get_seq_num();
  myTCP.open_socket();
  myTCP.check_bind();
  myTCP.check_listen();
  myTCP.go_listen();
  return 0;
}
开发者ID:fu908301,项目名称:Network_Programming,代码行数:14,代码来源:step6_server.cpp

示例13: _tmain

int _tmain(int argc, _TCHAR* argv[])
{
    TCP* tcp = new TCP();

    try
    {
        tcp->Startup();
        tcp->InitSocket();
        tcp->Connect(PORT, HOST);

        cout << "Input string to send: ";

        string s;
        cin >> s;

        tcp->SendData(s);
        cout << "Reseive: " << endl;
        cout << tcp->ReceiveData() << endl;
        tcp->CloseConnection();
    }
    catch (string error)
    {
        cout << error;
        tcp->CloseConnection();
    }
}
开发者ID:codeserfer,项目名称:7-term,代码行数:26,代码来源:client.cpp

示例14: assert

vector<EthernetII> FlowTest::chunks_to_packets(uint32_t initial_seq,
                                               const ordering_info_type& chunks, 
                                               const string& payload) {
    vector<EthernetII> output;
    for (size_t i = 0; i < chunks.size(); ++i) {
        const order_element& element = chunks[i];
        assert(element.payload_index + element.payload_size <= payload.size());
        TCP tcp;
        RawPDU raw(payload.begin() + element.payload_index, 
                   payload.begin() + element.payload_index + element.payload_size);
        tcp.seq(initial_seq + element.payload_index);
        output.push_back(EthernetII() / IP() / tcp / raw);
    }
    return output;
}
开发者ID:rklabs,项目名称:libtins,代码行数:15,代码来源:tcp_ip.cpp

示例15: TEST_F

TEST_F(PDUTest, OperatorConcat) {
    std::string raw_payload = "Test";
    IP ip = IP("192.168.0.1") / TCP(22, 52) / RawPDU(raw_payload); 
    EXPECT_EQ(ip.dst_addr(), "192.168.0.1"); 
    ASSERT_TRUE(ip.inner_pdu() != NULL);
    TCP *tcp = ip.find_pdu<TCP>();
    ASSERT_TRUE(tcp != NULL);
    EXPECT_EQ(tcp->dport(), 22);
    EXPECT_EQ(tcp->sport(), 52);
    ASSERT_TRUE(tcp->inner_pdu() != NULL);
    RawPDU *raw = tcp->find_pdu<RawPDU>();
    ASSERT_TRUE(raw != NULL);
    ASSERT_EQ(raw->payload_size(), raw_payload.size());
    EXPECT_TRUE(std::equal(raw_payload.begin(), raw_payload.end(), raw->payload().begin()));
}
开发者ID:Imva,项目名称:libtins,代码行数:15,代码来源:pdu.cpp


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