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

Author Topic: Receiving weird characters when using UDP  (Read 17269 times)

0 Members and 1 Guest are viewing this topic.

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Receiving weird characters when using UDP
« Reply #30 on: October 15, 2015, 10:45:58 pm »
Is this the way to do it then?
<code>

Well according to binary1248 a UDP socket can receive from itself and as you already said it works so no need for the second socket. But when it comes to sending stuff to your public IP and hoping it gets through that is an entirely different issue. You are most likely behind a NAT from your ISP so there is no way for you to allow incoming connections.

See: http://www.sfml-dev.org/faq.php#network-internet-network

Auch, indeed... You're right.
Will this work then, if I do port-forwarding?

Thanks a lot for the help all, by the way.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Re: Receiving weird characters when using UDP
« Reply #31 on: October 15, 2015, 11:45:53 pm »
Auch, indeed... You're right.
Will this work then, if I do port-forwarding?

You can forward all the ports you want on your router, but if you are sitting behind a NAT (from your ISP) there isn't much you can do. Google for more info, but basically ISPs implemented NATs because the internet was running out of IP addresses. The advantage to a NAT is that your ISP can group a whole bunch of customers behind a single public IP address. The disadvantage as you are experiencing is that you have no way to allow incoming connections (how is the NAT supposed to know which customer the intended data was for?).

In essence, your own home router is a NAT because it hides all of your other devices you have connected to it behind a single connection to the internet (through the ISP's modem). That is where port forwarding comes in, when you setup port forwarding the NAT (your router) now knows where to send incoming data for a specific port instead of just dropping it.

Generally ISPs offer a more expensive 'business' plan that includes a static public IP address which would then allow you to handling incoming connections (port forwarding) and host your own server.
« Last Edit: October 15, 2015, 11:51:02 pm by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Receiving weird characters when using UDP
« Reply #32 on: October 16, 2015, 01:26:17 am »

    +--------+                        +---------------------------+
    |        | ---- src = 55001 ----> | ---- randomize port ----> | --- src = 65432 ----+
    |   PC   |                        |          Gateway          |                     |
    |        | <----- ???             |   not mapped : drop <---- | <-- dst = 55001 ----+
    +--------+                        +---------------------------+

 
You made your life harder by using the same port to send and receive. If you use 2 different ports, you could port forward like zsbzsb said, but because you have to get into the hole that your outgoing data came out of, it is all down to guesswork if you use the same port. This is a feature (a good intended one) of stateful firewalls. It is meant to, among other things, protect you and your internal network. Instead of trying to circumvent it, you might want to consider alternate solutions if possible.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Receiving weird characters when using UDP
« Reply #33 on: October 16, 2015, 10:03:00 pm »
Auch, indeed... You're right.
Will this work then, if I do port-forwarding?

Generally ISPs offer a more expensive 'business' plan that includes a static public IP address which would then allow you to handling incoming connections (port forwarding) and host your own server.

So, not everyone can port-forward? Those with a 'cheaper' plan?
How do torrent-protocols and all other p2p applications work then?

Niely

  • Full Member
  • ***
  • Posts: 101
    • View Profile
Re: Receiving weird characters when using UDP
« Reply #34 on: October 16, 2015, 10:03:46 pm »

    +--------+                        +---------------------------+
    |        | ---- src = 55001 ----> | ---- randomize port ----> | --- src = 65432 ----+
    |   PC   |                        |          Gateway          |                     |
    |        | <----- ???             |   not mapped : drop <---- | <-- dst = 55001 ----+
    +--------+                        +---------------------------+

 
You made your life harder by using the same port to send and receive. If you use 2 different ports, you could port forward like zsbzsb said, but because you have to get into the hole that your outgoing data came out of, it is all down to guesswork if you use the same port. This is a feature (a good intended one) of stateful firewalls. It is meant to, among other things, protect you and your internal network. Instead of trying to circumvent it, you might want to consider alternate solutions if possible.

Thanks a lot.
I'll be using two different ports, one for receiving and one for sending.

 

anything