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

Pages: [1]
1
Well, it turned out that my compiler was probably the problem (when trying asio sockets), aka a recent mingw64 with C++17 support (found on SourceForge). Sorry for the troubles then !


... It was such a wasted week-end XD

2
What I tried to say is that, running or not another process do not change the output of the minimal program I wrote in my first post.

To put it simply : I want to know what I did wrong in the code sample (which is all I need in a main to recreates the problem), and if it works for anyone, know from where the error can come (can a wrong library bind cause something like this ? I use MinGW by the way)

3
I do not use the same socket for my two process (they are bound to different ports).

In fact, I ran exactly the given code and got the problem (of the Receive(...) call returning Disconect, the only difference was that I stdout'ed the status), and running the second process don't change the output of this one (or sending a packet with a second socket in the same process).

4
The Receive(...) call is supposed to returns "Not Ready" status, or "Done" if there is packet to poll (which happens as excepted until I call Send(...)). It's for a game, where I will send and receive informations in a loop. The code I wrote is only a minimal exemple to show my problem (there is another process that will communicate in the same way, to test my client / server code).

5
Hello,

First, thanks for this library and sorry if my question has an obvious / documented answer but I didn't find anything. Here is a code sample that recreates my issue (which is, getting a Disconnected socket status when calling socket.Receive(...) after socket.Send(...), even if I take a nap between the calls) :

sf::UdpSocket socket;
socket.bind(sf::Socket::AnyPort);
socket.setBlocking(false);

std::byte buffer[2000];
sf::IpAddress remoteIp = sf::IpAddress::LocalHost;
uint16_t remotePort = 42913;
size_t receivedSize;

assert(socket.getLocalPort() != remotePort);

std::this_thread::sleep_for(100ms);

// Status = Done
socket.send(buffer, 500, remoteIp, remotePort);

std::this_thread::sleep_for(100ms);

// Status = Disconnected
socket.receive(buffer, 1000, receivedSize, remoteIp, remotePort);

 

Maybe it has to do with sending the packet to myself, but it is very conveniant. Any idea ?

Pages: [1]