スクリプトです。
#uselib "ws2_32.dll"
#cfunc WSAStartup "WSAStartup" int, sptr
#func WSACleanup "WSACleanup"
#cfunc socket "socket" int, int, int
#func closesocket "closesocket" int
#cfunc bind "bind" int, sptr, int
#cfunc recv "recv" int, sptr, int, int
#cfunc recvfrom "recvfrom" int, sptr, int, int, sptr, sptr
#cfunc inet_addr "inet_addr" sptr
#cfunc htons "htons" int
#cfunc WSAGetLastError "WSAGetLastError"
#define AF_INET 2
#define SOCK_DGRAM 2
#define PORT 9999
sdim wsaData, 512;
sdim szDescription, 256;
sdim szSystemStatus, 128;
sdim sockaddr, 16;
sdim fromaddr, 16;
sdim szBuf, 1024;
hostname = "192.168.0.4";
fromlen = 160;
svaddr = inet_addr(varptr(hostname));
memset sockaddr, 0, 16
memset fromaddr, 0, 16
wpoke sockaddr, 0, AF_INET
wpoke sockaddr, 2, htons(PORT)
lpoke sockaddr, 4, svaddr
nRtn = WSAStartup(2, varptr(wsaData));
sock = socket(AF_INET, SOCK_DGRAM, 0);
nRtn = bind(sock, varptr(sockaddr), 16);
repeat
cls
nRtn = recv(sock, varptr(szBuf), 256, 0);
mes nRtn
mes szBuf
nRtn = WSAGetLastError();
mes nRtn
await 1
loop
closesocket(sock);
WSACleanup;