LAN and Internet Port Scanning

BlitzPlus Forums/BlitzPlus Beginners Area/LAN and Internet Port Scanning

Gladclef - Ben B(Posted 2010) [#1]
Hey guys. I want to write a networked game, but don't want to use the built in networking prompt (since it's windowed and kind of ugly). My question is, does anybody know if there's a way to do port scanning in Blitz?


xlsior(Posted 2010) [#2]
'just' keep trying ports until you have one that answers... the problem is that network calls in Blitzplus are 'blocking' (the program stops until the network communication is complete or times out), so it will be very time consuming to go through a long list of addresses/ports.

the proper way is to use the broadcast IP address to advertise yourself trying to find others: for example, if your IP address is 192.168.1.7, you can send a message to 192.168.1.255, and *all* computers in the 192.168.1.x subnet will receive the message and can take action on it, such as establishing a return connection.

(In most cases the x.x.x.255 address is the broadcast address, although it will be different in cases where you have smaller subnets... In that case you can calculate the address based on the netmask. No idea how to obtain the netmask information from within Blitz, though...)


Gladclef - Ben B(Posted 2010) [#3]
As to the problem of port scanning, my solution (which ...ahem... I feel was very elegant), was to create a secondary program which did the calls for a specific IP address given in the command line. When it found a game, it saved a new file containing the ip address and any other relevant information.

Still, your advice was awesome! Thanks for replying. Will use the broadcasting method.


Stamm(Posted 2010) [#4]
maybe a way to get the netmask:
b+ has DDE implemented now, so you colud call ipconfig and extract the data
would look like this:

ipconf=createprocess(systemproperty("windowsdir")+"whatever\ipconfig.exe")
repeat
s$=s$+chr(10)+readline(ipconf)
until eof(ipconf)

Of course replace whatever\ by the path of ipconfig in the windows directory, I think it's system32

then when you've exited the loop scan s$ for the ip, and if you want convert it to integer notation