Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ultrageek

Pages: [1]
1
Network / SFML window freezes while it waits for data to be received
« on: February 25, 2014, 11:41:38 am »
Hi guys.

Although I've already set my TCPSocket to non-blocking mode, the window still freezes (unresponsive) every single time when it is waiting for data to be received. I had tried to solve this problem with thread (with sleep and pause function) too but it didn't work though.  :(

2
Network / Re: Help needed! tcpSocket.receive(packet) keeps on failing.
« on: September 06, 2013, 07:51:17 pm »
I have actually done it at the very beginning  ;D Thank you for your help, it works fine now with SFML's fixed size types. However, it does not seem to work with 2D array with vectors?

First I would recommend against using 2D arrays. They generally just serve to make code more complicated.

As for your problem you really need to show some code of how your storing objects in a vector (probably your copying around an object somewhere).
Hi zsbzsb,
It does not seem to have another alternative to 2D array in my case :(
It is actually used to store numbers 0 and 1.

vector< vector<sf::Uint8> > grid;

for (int x=0; x<10; ++x)
{
      for (int y=0; y<10; ++y)
      {
        grid[ x ][y] = 0;
      }
}   

While under a condition, grid[ x ][y] will store 1 to indicate an existence in that particular slot.

And this data will be passed to the client.

Thank you in advance.  ;D

3
Network / Re: Help needed! tcpSocket.receive(packet) keeps on failing.
« on: September 06, 2013, 06:29:43 pm »
What about connecting your sockets first?
I have actually done it at the very beginning  ;D Thank you for your help, it works fine now with SFML's fixed size types. However, it does not seem to work with 2D array with vectors?

4
Network / Re: Help needed! tcpSocket.receive(packet) keeps on failing.
« on: September 06, 2013, 03:57:23 pm »
You write data once and then you read it twice, first in own line then in if.
Hi FRex, thank you for your reply!

Just in case: this is not the only error, so don't try to fix your code based on this, but read the tutorial instead ;)
I have read the tutorial, from line to line carefully, but I'm still so confused and lost  :(

EDIT: It seems that the problem is with variable type!

5
Network / Re: Help needed! tcpSocket.receive(packet) keeps on failing.
« on: September 06, 2013, 01:43:19 pm »
You obviously need to read the tutorial first.
Hi Laurent, thank you for your quick reply.

I have read the one regarding Packet, I thought I understood how it works but your comment here tells me I didn't...Can you please enlighten me? D:

6
Network / Help needed! tcpSocket.receive(packet) keeps on failing.
« on: September 06, 2013, 01:21:29 pm »
I have these 2 functions, I want server A to send a data packet to client B.

void A()
{
        sf::TcpSocket socket;
        sf::Packet packet;

   int test1 = 1;
   float test2 = 1.0f;
   double test3 = 1.111;
   packet << test1 << test2 << test3;
   
   socket.send(packet);
}

void B()
{
          sf::Packet packet;
   sf::TcpSocket socket;

        socket.receive(packet);
   
   int test1;
   float test2;
   double test3;
   
   packet >> test1 >> test2 >> test3;
   if (packet >> test1 >> test2 >> test3)
   {      
      cout << test1 <<" " << test2 << " " << test3 << endl;
   }
   else
   {
      cout << "Failed" << endl;
   }
}

Anything wrong with my code? When I test the program, "Failed" is always displayed instead of working correctly.
   

Pages: [1]