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 - nuvw

Pages: [1]
1
Network / TcpSocket crashes server.
« on: January 01, 2011, 03:50:21 pm »
I looked further into this and it seems that the server process is getting a SIGPIPE signal, which causes it to terminate.

The problem has already been mentioned earlier:
http://www.sfml-dev.org/forum/viewtopic.php?t=945&start=0&postdays=0&postorder=asc&highlight=

I am not sure, but wouldn't this be something that could be handled by SFML?

2
Network / TcpSocket crashes server.
« on: January 01, 2011, 03:22:06 pm »
I am not sure whether I understand what you try to say.

The problem is that the server dies right after the call to TcpSocket::Send. So any test that comes after that call is meaningless.

3
Network / TcpSocket crashes server.
« on: January 01, 2011, 03:25:59 am »
Hello everyone

I am having some issue with TcpSockets. As this is the first time that I look into network programming, it might as well be that I overlook something general about networks and sockets. However, here it is:

Imagine the following server and client interacting.

Server:
Code: [Select]

#include <iostream>

#include <SFML/Network.hpp>

int main()
{
  sf::TcpListener listener;
  listener.Listen( 55555 );
 
  sf::TcpSocket clientSocket;
  listener.Accept( clientSocket );
 
  sf::Sleep( 1.0 );
 
  sf::Packet packet;
  packet << (float)42.0;
 
  clientSocket.Send( packet ); // server crashes here

  while( true )
  {
    std::cout << "I am a good server who likes to loop forever." << std::endl;
    sf::Sleep( 1.0 );
  }
}


Client:
Code: [Select]

#include <iostream>

#include <SFML/Network.hpp>

int main()
{
  sf::TcpSocket socket;
  socket.Connect( sf::IpAddress::LocalHost, 55555 );
 
  std::cout << "I am an evil client who likes to quit without cleaning up!" << std::endl;
}


As already mentioned in the code, the server crashes as soon as it tries to send a packet to the client, which has terminated a long time ago.

I know that the above code for the client is far from good. However, this is not the issue here. What bothers me is that a bad client (or even an unstable one, which crashes frequently) can easily cause the server to crash as well. I do not see any possibility to use SFML's sockets in a safer way than that.

Note: Before I switched to version 2.0 I experienced the exact same problem in 1.6.

4
Window / [Solved] Input Problem!
« on: June 27, 2008, 05:14:50 pm »
I don't know whether any two of us have got the same problem. :roll: But after having played around with my code I have found at least a solution for me. Maybe it helps one of you ...

Following function does not work how I want it to (it always returns false):

Code: [Select]
bool IsADown()
{
  const sf::Input& input = myWindow->GetInput();    // myWindow is a pointer to my RenderWindow

  if( input.IsKeyDown(sf::Key::A) )
  {
    return true;     // never happens
  }

  return false;  
}


Note: The Input instance always seems to return default values (all keys are released, mouse coordinates are 0/0, etc.)

If I expand my function with some (in my eyes needless) code, it works flawlessly:

Code: [Select]
bool IsADown()
{
  sf::Event event;
  myWindow->GetEvent(event);      // this seems to make the difference

  const sf::Input& input = myWindow->GetInput();

  if( input.IsKeyDown(sf::Key::A) )
  {
    return true;     // now it works perfectly
  }

  return false;  
}


Question: Is it really intentional that one has to call GetEvent(event) before accessing the Input instance?


Apart from that: Great library, I love it! Keep up the great work  :)

5
Window / [Solved] Input Problem!
« on: June 26, 2008, 09:14:09 pm »
I've got exactly the same problem since sfml 1.3.

I'm working on Ubuntu 8.04 with g++.

Pages: [1]