|
Post by pandawdy on Sept 28, 2019 16:09:15 GMT -5
On the Liberty Basic Yahoo group I was able to find this function for sending data over UDP:
function UDPsend(addr$, port, msg$)
AF.INET = 2
SOCK.DGRAM = 2
IPPROTO.UDP = 17
UDPsend = 0
port = (port and hexdec("FF00")) / 256 + (port and 255) * 256 ' swap bytes
calldll #winsock, "inet_addr", addr$ as ptr, ipaddr as ulong
struct WSAdata, d as char[398]
calldll #winsock, "WSAStartup", 514 as long, WSAdata as struct, ret as long
if ret then exit function
calldll #winsock, "socket", AF.INET as long, SOCK.DGRAM as long, _
IPPROTO.UDP as long, socket as long
if socket = -1 then exit function
struct addr, family as short, port as short, addr as ulong, zero as char[8]
addr.family.struct = AF.INET
addr.port.struct = port
addr.addr.struct = ipaddr
al = len(addr.struct)
ml = len(msg$)
calldll #winsock, "sendto", socket as long, msg$ as ptr, ml as long, _
0 as long, addr as struct, al as long, sent as long
calldll #winsock, "closesocket", socket as long, ret as long
calldll #winsock, "WSACleanup", ret as long
if sent = ml then UDPsend = 1
end function
This seems to work great for sending data out... does anyone have any idea how to receive data over UDP using winsock?
I have programmed some useful things, but API's are beyond me right now.
|
|
|
Post by pandawdy on Sept 28, 2019 16:15:47 GMT -5
It sure would be great if Liberty Basic 5 could handle UDP and TCP without extra DLL's.
|
|
|
Post by Carl Gundel on Sept 28, 2019 16:35:59 GMT -5
It sure would be great if Liberty Basic 5 could handle UDP and TCP without extra DLL's. It's possible, but probably will have to wait for LB 5.1.
|
|
|
Post by pandawdy on Oct 2, 2019 11:38:16 GMT -5
I managed to find out who wrote the original function and contacted him. He said he can't write code like he used to and wouldn't know how to write a similar function to receive UDP. Bummer
|
|