here you go:
set display mode 800, 600, 32
set window on
dim args() as string
args$ = CL$()
if args$ > ""
array insert at bottom args()
args() = first token$(args$, " ")
repeat
a$ = next token$(" ")
if a$ > ""
array insert at bottom args()
args() = a$
endif
until a$ = ""
endif
hSocket = new udp socket()
if hSocket > 0
if args(0) = "-s"
didBind = bind socket(hSocket, intval(args(1)))
if didBind
print "UDP Socket bound to port " + args(1)
else
print "Failed to bind socket"
endif
else
didConnect = connect socket(hSocket, hostname to ip(args(0)), intval(args(1)))
if didConnect
print "UDP Socket connected to " + args(0) + ":" + args(1)
res = send socket string(hSocket, "Hello from new connection")
else
print "failed to connect"
endif
endif
endif
do
if socket poll read(hSocket) = 1
msg$ = recv socket string$(hSocket)
if msg$ <> ""
print msg$
endif
endif
loop
run the .exe from the command line, you will run the first instance using 'application.exe -s 9999' then run a second instance using 'application.exe 127.0.0.1 9999'
windows firewall may ask you to allow the application.
You will see the first instance report that it has bound the socket. You will see the second instance report that it has connected and you will see the message sent by the second instance received and printed by the first instance.
A single player RPG featuring a branching, player driven storyline of meaningful choices and multiple endings alongside challenging active combat and intelligent AI.