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


C++ TcpSocket::receive方法代码示例

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


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

示例1: c_communication

void c_communication(c_serveur& sett)
{
    TcpSocket svr;
    svr.connect(sett.c_ip,55001);
    c_infoPlayer<<c_pseudo;
    svr.send(c_infoPlayer);



    cout<<"Communication lancee"<<endl;
    while(c_connected)
        {
            c_attendre.lock();
            svr.send(c_sortant);
            c_sortant.clear();
            c_sortant<<false<<"";
            c_attendre.unlock();
            bool a;
            string b;
            if(svr.receive(c_entrant) == Socket::Done)
            {
                //system("cls");
                c_entrant>>a>>b;
                if(!a)
                c_msgsRecus = b;

            }
            else
            {
开发者ID:Gthebeast,项目名称:Bac_a_sable_SFML2,代码行数:29,代码来源:client.cpp

示例2: receive_curve

CurveRef receive_curve(TcpSocket& stream)
{
	Packet pkt;
	stream.receive(pkt);
	
	string curveData;
	pkt >> curveData;
	
	return CurveCreateFromData(curveData.c_str());
}
开发者ID:Ceylo,项目名称:CryptoA5,代码行数:10,代码来源:network.cpp

示例3: main

int main()
{

	socket.receive(recvChar, 1024, received);
	cout << recvChar << endl;

	Socket::Status status = socket.connect("localhost", 10006);
	socket.send(sendChar, 1024);

	return 0;
}
开发者ID:Treache,项目名称:TanksGod,代码行数:11,代码来源:main.cpp

示例4: client_receive_key

PointRef client_receive_key(TcpSocket& stream)
{
	Packet pkt;
	stream.receive(pkt);
	
	string peerXString, peerYString;
	pkt >> peerXString;
	pkt >> peerYString;
	
	mpz_t peerX;
	mpz_t peerY;
	
	mpz_init_set_str(peerX, peerXString.c_str(), 10);
	mpz_init_set_str(peerY, peerYString.c_str(), 10);
	
	PointRef peerKey = PointCreateFromGMP(peerX, peerY);
	mpz_clears(peerX, peerY, NULL);
	
//	cout << "Received remote key: " << PointCreateDescription(peerKey) << endl;
	
	return peerKey;
}
开发者ID:Ceylo,项目名称:CryptoA5,代码行数:22,代码来源:client.cpp

示例5: own_thread

void Client::own_thread()
{
    TcpSocket sock;
    sock.connect( m_host, m_port );

    unsigned int version = 1;
    unsigned int options = 0;

    sock.send( version );
    sock.send( options );
    // first send size of name.
    sock.sendString( m_name );

    unsigned int images = 0;
    unsigned int width = 0;
    unsigned int height = 0;
    unsigned int bpp = 0;
    try
    {
        sock.receive( images );
        sock.receive( width );
        sock.receive( height );
        sock.receive( bpp );
    } catch( std::string a_error )
    {
        std::cerr << a_error << std::endl;
        return ;
    }
    std::cout << "DEBUG: " << "images: " << images << " w: " << width << " h: " << height << " bpp: " << bpp << std::endl;

    std::unique_ptr< sepia::Writer > data = std::unique_ptr< sepia::Writer >( new sepia::Writer( m_name, images, width, height, bpp ) );


    int more = 0; // more data available if true.
    while( !m_terminate )
    {
        for( int i = 0; i < data->getGroupHeader()->count; i++ )
        {
            sock.receive( *data->getHeader( i ) );
            sock.receive( data->getAddress( i ), data->getSize( i ) );
        }
        data->update();
    }
}
开发者ID:SorcererX,项目名称:SepiaStream,代码行数:44,代码来源:client.cpp

示例6: sendRecv

////////////////////////////////////////////////////send & recv from server
void sendRecv()
{
	while (1)
	{
		socket.receive(recvChar, 1024, received);
		cout << recvChar << endl;

		if (recvChar[0] != anotherClient)
		{
			for (int i0 = 0; i0 < tank.size(); i0++)
			{
				sendChar[i0] = playerButton[i0];
			}

			for (int i1 = 0; i1 < tank.size(); i1++)
			{
				for (int i2 = 0; i2 < 7; i2++)
				{
					tank[i1].button[i2] = recvChar[7 * i1 + i2];
					cout << tank[i1].button[i2] << endl;
				}
			}
			///making send char for normal use
			sendChar[0] = playerID;
			for (int i0 = 0; i0 < 7; i0++)
			{
				sendChar[i0 + 1] = playerButton[i0];
			}
			socket.send(sendChar, 1024);
		}
		else
		{
			sendChar[0] = wall.size();
			for (int j0 = 0; j0 < wall.size(); j0++)
			{
				sendChar[wall[j0].tedadeVizhegiha*j0 + 1] = wall[j0].ID;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 2] = wall[j0].centerPoint.x;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 3] = wall[j0].centerPoint.y;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 4] = wall[j0].length;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 5] = wall[j0].width;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 6] = wall[j0].leftUpPoint.x;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 7] = wall[j0].leftUpPoint.y;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 8] = wall[j0].rightDownPoint.x;
				sendChar[wall[j0].tedadeVizhegiha*j0 + 9] = wall[j0].rightDownPoint.y;
			}
			sendChar[(wall.size()*wall[0].tedadeVizhegiha) + 1] = bullet.size();
			for (int j0 = wall.size()*wall[0].tedadeVizhegiha + 1; j0 < wall.size()*wall[j0].tedadeVizhegiha + 1 + bullet.size(); j0++)
			{
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 1] = bullet[j0].ID;
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 2] = bullet[j0].tankID;
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 3] = bullet[j0].centerPoint.x;
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 4] = bullet[j0].centerPoint.y;
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 5] = bullet[j0].radius;
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 6] = bullet[j0].velocity.x;
				sendChar[bullet[j0].tedadeVizhegiha*j0 + 7] = bullet[j0].velocity.y;
			}
			sendChar[wall.size()*wall[0].tedadeVizhegiha + (bullet.size()*bullet[0].tedadeVizhegiha) + 2] = tank.size();
			for (int j0 = wall.size()*wall[0].tedadeVizhegiha + (bullet.size()*bullet[0].tedadeVizhegiha) + 2; j0 < wall.size()*wall[0].tedadeVizhegiha + (bullet.size()*bullet[0].tedadeVizhegiha) + tank.size() + 2; j0++)
			{
				sendChar[tank[j0].tedadeVizhegiha*j0 + 1] = tank[j0].forwardVelocity;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 2] = tank[j0].backwardVelocity;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 3] = tank[j0].bodyRotationVelocity;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 4] = tank[j0].pipeRotationVelocity;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 5] = tank[j0].vecForwardVelocity.x;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 6] = tank[j0].vecForwardVelocity.y;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 7] = tank[j0].vecBackwardVelocity.x;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 8] = tank[j0].vecBackwardVelocity.y;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 9] = tank[j0].ID;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 10] = tank[j0].centerPoint.x;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 11] = tank[j0].centerPoint.y;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 12] = tank[j0].length;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 13] = tank[j0].width;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 14] = tank[j0].bodyDegree;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 15] = tank[j0].bodyRotateSpeed;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 16] = tank[j0].pipeDegree;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 17] = tank[j0].pipeRotateSpeed;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 18] = tank[j0].velocity.x;
				sendChar[tank[j0].tedadeVizhegiha*j0 + 19] = tank[j0].velocity.y;
			}
		}

		for (int i = 0; i < recvChar[0]; i++)
		{
			wall[i + 1].ID = recvChar[i*wall[0].tedadeVizhegiha + 1];
			wall[i + 1].centerPoint.x = recvChar[i*wall[0].tedadeVizhegiha + 2];
			wall[i + 1].centerPoint.y = recvChar[i*wall[0].tedadeVizhegiha + 3];
			wall[i + 1].length = recvChar[i*wall[0].tedadeVizhegiha + 4];
			wall[i + 1].width = recvChar[i*wall[0].tedadeVizhegiha + 5];
			wall[i + 1].leftUpPoint.x = recvChar[i*wall[0].tedadeVizhegiha + 6];
			wall[i + 1].leftUpPoint.y = recvChar[i*wall[0].tedadeVizhegiha + 7];
			wall[i + 1].rightDownPoint.x = recvChar[i*wall[0].tedadeVizhegiha + 8];
			wall[i + 1].rightDownPoint.y = recvChar[i*wall[0].tedadeVizhegiha + 9];
		}
		for (int i = (recvChar[0] * wall[0].tedadeVizhegiha) + 1; i < recvChar[(recvChar[0] * wall[0].tedadeVizhegiha) + 1]; i++)
		{
			bullet[i + 1].ID = recvChar[(recvChar[0] * wall[0].tedadeVizhegiha) + (i*bullet[0].tedadeVizhegiha) + 2];
			bullet[i + 1].tankID = recvChar[(recvChar[0] * wall[0].tedadeVizhegiha) + (i*bullet[0].tedadeVizhegiha) + 3];
			bullet[i + 1].centerPoint.x = recvChar[(recvChar[0] * wall[0].tedadeVizhegiha) + (i*bullet[0].tedadeVizhegiha) + 4];
			bullet[i + 1].centerPoint.y = recvChar[(recvChar[0] * wall[0].tedadeVizhegiha) + (i*bullet[0].tedadeVizhegiha) + 5];
//.........这里部分代码省略.........
开发者ID:Treache,项目名称:TanksGod,代码行数:101,代码来源:main001.cpp


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