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

Author Topic: UDP and close ports  (Read 2174 times)

0 Members and 3 Guests are viewing this topic.

koker_007

  • Newbie
  • *
  • Posts: 7
    • View Profile
UDP and close ports
« on: February 07, 2017, 03:39:11 pm »
Hello, i'm writing a small multiplayer game of SFML only use network. I am sure that the client has closed the port used and was always closed. At first, when I was studying SFML Network, I used a TCP connection. It worked. The server receives a message from a client, and the client received from the server. But when I moved to the UDP, the server is also received reports, however, the client from the server - no. I know what is to blame for a closed port on the client side.
When SFML server sends the packet to the UDP, back comes a message that returns the status of sf::packet::status::Disconnected. SFML's documentation said that the "The TCP socket has been disconnected".
this status is returned even if my game is not active at the client.

Please explain why this is happening and how to get around using the UDP connection. Many games use UDP connection, but the client receives information from the server when the closed ports. How???

koker_007

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: UDP and close ports
« Reply #1 on: February 08, 2017, 12:40:30 pm »
I'm a little progress in understanding what is happening. Now I want to know whether there is a SFML function that returns a number of the open port of the user? To me it is necessary to allow the server to send packet to the open port on the client.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: UDP and close ports
« Reply #2 on: February 09, 2017, 12:54:47 pm »
I don't fully understand your problem.

You have to bind your UDP socket for client and server to some port. Which port you pick is up to you and unless you have some firewall blocking certain ports, the system doesn't need to provide possible "open" ports.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/