Jump to content
  • Advertisement
Sign in to follow this  
try_catch_this

Problem sending over more than one channel on enet.

This topic is 5065 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I can send on channel 0 but when I try channel 1 it isnt recived.
void MainWindow::SendToClient( char *data, long length, int index, int channel, int flag )
{
   // Create a packet of size lenght containing data
   ENetPacket * packet = enet_packet_create( data, 
                                             length, 
                                             flag );
    
    // Send the packet to the peer over channel id channel. 
    // One could also broadcast the packet by         
    // enet_host_broadcast( m_Server, channel, packet );
    enet_peer_send( &m_Server->peers[index], channel, packet );

    // One could just use enet_host_service() instead. 
    enet_host_flush( m_Server );
}

void MainWindow::CreateClient()
{
   m_Client = enet_host_create( NULL, // create a client host
                                ENET_CHANNEL_SIZE-1,    // Is this is for peers, or channels?
                                57600 / 8,   // 56K modem with 56 Kbps downstream bandwidth
                                14400 / 8 ); // 56K modem with 14 Kbps upstream bandwidth 

   if( m_Client == NULL )
   {
      m_Mutex.Lock();
      m_Console.AddLine( "An error occurred while trying to create an ENet client host." );
      m_Mutex.Release();
   }
   else
   {
      m_Mutex.Lock();
      m_Console.AddLine( "An enet client was successfully created." );
      m_Mutex.Release();
   }
}

      // network channels
      enum 
      {
         ENET_CHANNEL_TEXT = 0,
         ENET_CHANNEL_COMMAND,
         ENET_CHANNEL_POSITION,
         ENET_CHANNEL_SIZE,
      };

      enum 
      {
         COMMAND_START = 1,
         COMMAND_NEW_ROUND,
      };


Try to send like this: SendToClient( (char*)&command, sizeof(command), 0, ENET_CHANNEL_COMMAND, ENET_PACKET_FLAG_RELIABLE ); If I dont figuer why this isnt working I will have to make my own packet class which adds alot of overhead to what enet does already.

Share this post


Link to post
Share on other sites
Advertisement
are you sure your specifying the right number of channels when connecting? i believe the parameter is in the call to enet_host_connect(). make sure you specified enough channels here.

Share this post


Link to post
Share on other sites
btw, if you like eNet, you might really love RakNet. i switched over from eNet to RakNEt towards the end of my online pong clone and never looked back. it has a much more elegant system and better docs and support. nothing against enet though, its a nice lib as well, but its hard to find answers to questions you might have, and its not as high level as i like. also, you wouldnt need to use threads with it. why are you using threads anyway? eNet doesnt really require them, except maybe for connecting.

anyway, good luck.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!