BNetEx, UDP send and receive on the same computer

BlitzMax Forums/BlitzMax Programming/BNetEx, UDP send and receive on the same computer

LAB[au](Posted 2008) [#1]
Hi!

On blitz3d I would use 2 UDP streams, one for receive (ex. port 2005) and one for sending (ex. port 2004). This allowed to send and receive from the same program, effectively creating a sort of peer to peer network. I would then broadcast all UDP messages by sending to xxx.xxx.xxx.255

Now I try to achieve the same with BNetEx from Vertex, I opened the examples which are all client/server, and I am totally confused the setremoteIP, setremoteport, setlocalport methods.

I tried setting local and remote port to the same number using only one stream for send and receive, but it didn't work completely, sometimes messages are "inetercepted" by a computer then the other ones don't get the message. It is not always the same computer that intercept it, so I don't get it.

I tried then making 2 UDP streams, one for send, one for receive, localport set to 2004 and 2005 respectively and I receive nothing...

Anyone has an example of a working send/receive UDP architecture, with boradcasting?

Thanks


Retimer(Posted 2008) [#2]
Raknet?

http://blitzmax.com/Community/posts.php?topic=72982


TaskMaster(Posted 2008) [#3]
Broadcasting can be blocked by hardware. So, relying on it could be bad. Many switches will block broadcasting and not allow it.

Broadcasting could also be sent out a persons Internet connection which could then be considered port scanning by their ISP which could get there connection cut off.


markcw(Posted 2008) [#4]
Can you use Gnet with BMax?


Vertex(Posted 2008) [#5]
SuperStrict

Framework BRL.Blitz
Import Vertex.BNetEx

Local adapterInfo : TAdapterInfo, ..
      stream      : TUDPStream

TNetwork.GetAdapterInfo(adapterInfo)

stream = New TUDPStream
stream.Init()
stream.SetLocalPort()                     ' Port of the stream, giving by OS
stream.SetRemotePort(1234)                ' Port where messages have to send
stream.SetRemoteIP(adapterInfo.Broadcast) ' IP-Address where messages have to send
stream.SetBroadcast(True)                 ' Enable broadcasting

' Send a broadcast message
stream.WriteLine("Hello to all!")
While stream.SendMsg()
Wend

' Close stream
stream.Close()
End


This should work.

cu olli


LAB[au](Posted 2008) [#6]
Yes it works. It was me who was using an old version of BNetEx... Thanks for the help.


Lykaestria(Posted 2008) [#7]
Quote: TaskMaster
Broadcasting can be blocked by hardware. So, relying on it could be bad. Many switches will block broadcasting and not allow it.

Broadcasting could also be sent out a persons Internet connection which could then be considered port scanning by their ISP which could get there connection cut off.

Surely this doesn't mean the UDP system of Vertex' BNetEx is fundamentally flawed does it? Cos I've only just finally found a networking lib that I can actually get my head around and understand :-\


Winni(Posted 2008) [#8]
No, this isn't a flaw in the lib. It only means that you should be careful with you do.