Author Topic: Catch all messages on a specific port  (Read 2121 times)

col000r

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 3
  • Posts: 43
  • Mighty Emperor of Planet "Home Office"
    • View Profile
    • BLACKISH
Catch all messages on a specific port
« on: June 09, 2014, 07:09:24 AM »
I'm using my own UDP solution to connect an external control system to my game and it all works really well. (it's very simple, the control system sends a constant stream of values and I translate them back into usable signals to move or rotate transforms via System.Net.Sockets.UdpClient)

Now I'm using TNet to make this multiplayer. The idea is that it's a normal networking situation, all handled via TNet, only one specific player will get the UDP signals from the control system and will then delegate the actual scene-changes to the rest of the players - again via TNet. (let's say the control system connects to 192.168.0.235:8000 and TNet connects to 192.168.0.235:5127)

But for some reason the two don't work at the same time?

If I disable the TNet part the control system works, if I enable TNet all the TNet-stuff works, but the control system doesn't receive any signals.
How can I fix this? Is TNet catching all signals?


Okay. User error. Got it to work! *doh*

But now I'm wondering: Would it be possible to rewrite my solution using TNet?
Is there a way to use TNet to simply listen to a specific UDP port and look-at/use all incoming messages? (A typical message would look something like this: "pos|0|1|2#rot|0|180|0")

Thank you very much for your help!
« Last Edit: June 09, 2014, 07:45:34 AM by col000r »
Games: BLACKISH | Blog | Assets

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Catch all messages on a specific port
« Reply #1 on: June 10, 2014, 03:27:22 AM »
Simply listen to a specific port via TNManager.StartUDP.

TNManager.EndSend() can be called with a target IPEndPoint, which will cause this message to be sent via UDP to the specified destination. Similarly, TNObject's BroadcastToLAN function can be used to send a UDP message to everyone listening to the specified port on the local area network.