Getting IP and Port of EnetPeers?

BlitzMax Forums/BlitzMax Module Tweaks/Getting IP and Port of EnetPeers?

Steffenk(Posted 2006) [#1]
Greetings,
I've recently tried to make a more usable wrapper of the enet library http://enet.cubik.org because i felt a lack of a fast (udp) low-level network library with optional reliable packets, traffic limitation, etc. - all the stuff you could ask for when doing multiplayer games and not being content with high-level-libs.

BRL had begun to wrap it for their gnet-hi-lvl-stuff but just as far as they needed it. Next i found ozak's wrapper which looked nice, but still obligated you to use several enet commands mixed with other functions. So i made my one wrapper and it already works as far as that i can connect and disconnect and send (un/reliable) packets. Which is pretty much everything i need.

Now the problem is that i have no idea how to get the IP and Port of other peers (PCs you're connected to). I don't really need it but the wrapper/lib just doesn't feel complete without that feature.

BRL's wrapper had a function for it but as far as i can tell, it doesn't work. ENet saves the ip/port in the ENetPeers structure, as can be seen in the documentation on their homepage - which is quite nice by the way. I can't extern that one because i ran into several problems when doing so, i.e. i need to save them in TLists, etc. BRL just did it with pointer arithmetics:

Local ip=(Int Ptr peer)[0]

As mentioned, this doesn't work for me and they don't use it in gnet either. I'm quite new to wrapping c++ libraries therefore i hope someone here can help me.


Steffenk(Posted 2006) [#2]
Ok, got it working now. I played a bit with the numbers in the angular brackets and with [3] for IP and [8] for port it worked. The client's port is a bit weird though (33009 or so), that's probably the reason why i didn't find it before.

I'll implement some last things like reading ping and packetloss from enet and test the whole thing intensively, then i'll possibly post the results here.

Oh, by the way, isn't anyone here interested in an enet-wrapper which is used similarly to BNet(Ex) and has optional reliable packets?