BASIC Developer & Support Resources > Scripting Languages

Scriptbasic: SOCK module

(1/1)

AIR:
I started writing this because the default SOCKET interface doesn't support UDP, etc.

Also, the old ssocket module has some weird stuff going on in it.

Not finished yet, but here is an example:


--- Code: Script BASIC ---import sock.bas ' CREATE NEW **UDP** CONNECTIONconn = SOCK::NEW(SOCK::AF_INET, SOCK::SOCK_DGRAM, SOCK::IPPROTO_IP) ' SET THE SOCKET CONNECTION PARAMETERS' SERVER, CONNECTION TYPE, PORT' FOR RETRIEVING LOCAL IP NON-EXISTANT SERVER IS OKAYSOCK::SET("1.0.0.0",SOCK::AF_INET,1) ' CONNECTSOCK::CONNECT(conn) ' RETRIEVE IP OF **DEFAULT** ADAPTER' DOESN'T MATTER IF IT IS ETHERNET OR WIFI' THE IP OF THE DEFAULT ADAPTER IS RETURNEDprint "Active IP: ",SOCK::GETIP(conn),"\n" 
riveraa@dpi:~/Projects/sb $ ./sb.AppImage socktest.bas
Active IP: 192.168.1.64


For most cases, the built-in SOCKET should suffice, this is more for those instances when you need more configuration options (like UDP support).
 
AIR.

John:
A major isssue with the built in socket support is there is no timeout and will hang the connection.

Navigation

[0] Message Index

Go to full version