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

Author Topic: Sending several times without receive  (Read 2952 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Sending several times without receive
« on: March 29, 2013, 10:38:41 pm »
What happens if I send a few times via udp or tcp without receiving anything on the other end(not that the other end dropped out or such, just that sends pile up before I receive them)?
I assume it's ok but might reorder the udp packets?
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Sending several times without receive
« Reply #1 on: March 30, 2013, 12:15:54 am »
binary has added some valuable stuff to the FAQ on networking, maybe it helps. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Sending several times without receive
« Reply #2 on: March 30, 2013, 01:11:23 am »
I guessed TCP is reliable, it doesn't really say for UDP but it makes me worry that I'll be polling my few TCP, listener and one or few UDP sockets for data every game cycle, at what point is it worth spawning a thread and placing a blocking selector there?
Would it make sense to call wait with extremely small timeouts(way under millisecond) each game cycle? I'd want to keep things mono threaded, UDP is going to receive and send new data every cycle anyway so there is no 'overhead' to be had there.
« Last Edit: March 30, 2013, 04:15:03 am by FRex »
Back to C++ gamedev with SFML in May 2023

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Sending several times without receive
« Reply #3 on: March 31, 2013, 03:56:48 am »
You don't have to "block" with a selector. Just tell it to return immediately (in essence just pass it sf::Time::microseconds( 1 ), your application won't run fast enough for that to make a difference anyway ;) ) and act if a socket is ready.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Varonth

  • Newbie
  • *
  • Posts: 11
    • View Profile
    • Email
Re: Sending several times without receive
« Reply #4 on: March 31, 2013, 05:39:30 pm »
It depends on how much data you are sending inbetween each subsequent receive call.

Each TcpSocket has a receive buffer, which will store data until it is read by it's recv function. If the buffer is full the other sides send will either wait until the it can actually send more data in case of a blocking socket, or in non-blocking mode return EWOULDBLOCK or EAGAIN.

The size of the Tcp buffer is depending on the system, for example MSDN says the standard receive buffer size in windows is 8192 bytes.

Edit:
Forgot to mention what a UDP socket does, but I guess that is pretty clear.
Cannot fit into the buffer? Well then... drop it ^^

Edit2:
Just looked at the SocketImpl at it appears that in case of an EWOULDBLOCK (and its windows equivalent WSAEWOULDBLOCK) error from the Socket, the SFML status would be Socket::NotReady, and in case of EAGAIN it would just be Socket::Error.
« Last Edit: March 31, 2013, 05:49:16 pm by Varonth »

 

anything