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

Author Topic: [SOLVED]Receiver stops working after a while  (Read 3045 times)

0 Members and 1 Guest are viewing this topic.

Abramovici

  • Newbie
  • *
  • Posts: 3
    • View Profile
[SOLVED]Receiver stops working after a while
« on: December 18, 2013, 02:10:02 am »
I am using SFML for my application and I use a socket to listen to the data being outputted by another application in the same machine. However, after a few cycles, the socket stops working. In blocking mode it completely freezes my application, while in non-blocking mode it fails to get the data and keeps using the last one before freezing. A snippet of the code used is below

sf::IpAddress Address = sf::IpAddress::LocalHost;
sf::TcpSocket socket;
socket.disconnect();
sf::TcpListener listener;
socket.connect(Address, port);
//socket.setBlocking(false);

void update()
{
        std::size_t received;
        if (socket.receive(buffer, sizeof(buffer), received)!= sf::Socket::Done)
                printf("could not get data");
}
 

Any clues as to what might cause this issue? The data is generated trough a labview application and send 336 bytes burst at a time (I tried using the buffer smaller, bigger and exactly, with issues in all of them).


FSML 2.1, windows 7 32 bits, Visual Studio 10 express
« Last Edit: December 20, 2013, 04:44:35 am by Abramovici »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11033
    • View Profile
    • development blog
    • Email
AW: Receiver stops working after a while
« Reply #1 on: December 18, 2013, 07:41:30 am »
You'd be best off running some network analysis tool, yo figure out what exactly happens.
You also should post a complete but minimal example, otherwise it might be a problem in your code an weull never notice due to lack of code. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Abramovici

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Receiver stops working after a while
« Reply #2 on: December 19, 2013, 04:22:57 am »
It's not that I don't want to share my code, is that my code is pretty much it. It receives the data and processes it, before fetching the next packet. The issue might be caused on the server side. I am investigating this issue right now in the labview code.

Thanks anyway for the help

Abramovici

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Receiver stops working after a while
« Reply #3 on: December 20, 2013, 04:44:20 am »
Just some closure if anyone finds this topic:

I found that the problem was that the labview client was sending data too fast and overflowing the buffer, which essentially lent to the server crashing. I updated my program so that it fetches data at 5 times the previous rate, and this makes it so that both can communicate better.

 

anything