PDA

View Full Version : UDP listener script



dcantera
27-05-2008, 06:19
here is a task that I have been playing with and it was the point of my search for a basic interpretor/compiler.

a UDP listener

there wasn't enough docs/examples for me to do it on my own... here is what I have so far.


Uses "INet" '---Load INet module
Uses "RAS" '---Load RAS module
Uses "FILE" '---Load FILE module
Uses "TCPUDP" '---Load TCPUDP module
Uses "OS" '---Load OS module
Uses "CONSOLE" '---Load CONSOLE module

DIM pbxip AS LONG
DIM pbxname AS STRING
DIM udpconnid AS LONG
pbxip = HOSTNAME_TOIP("pbv01")
pbxname = HOSTIP_TONAME(pbxip)
Msg = "pbxip=" + pbxip + $CRLF
Msg += "pbxname=" + pbxname + $CRLF
MSGBOX(1,Msg)

udpconnid = UDP_Open(9009,UDP_FreeFile)

Do
INCR Count
sBuffer = UDP_Recv(udpconnid)
Msg = sBuffer
IF (Len(Msg) < 3) THEN
Msg = "hello"
END IF
MSGBOX(1,Msg)
Console_WriteLine Msg
Loop While ((Len(sBuffer) > 0) AND (ERR = 0))

UDP_Close(udpconnid)

ErosOlmi
27-05-2008, 16:20
Dave,

thanks for this script.
I include to this post an old example I have made with Petr. It is a simple console chatting. Maybe it can help others. Just open the script into different computers and exchange each other IPs.

Ciao
Eros

dcantera
28-05-2008, 05:25
way cool!...
this gives me more info to accomplish my listener tool project.
I really like the simplicity of thinbasic. it is a really cool tool for my toolbox.
thanks,
daveC