' TCP Client via Winsock DECLARE — socket, connect, send, recv
#COMPILE EXE
#DIM ALL

DECLARE FUNCTION WSAStartup LIB "WS2_32.DLL" (BYVAL wVersionRequired AS LONG, BYREF lpWSAData AS LongPtr) AS LONG
DECLARE FUNCTION WSACleanup LIB "WS2_32.DLL" () AS LONG
DECLARE FUNCTION socket LIB "WS2_32.DLL" (BYVAL af AS LONG, BYVAL type AS LONG, BYVAL protocol AS LONG) AS LONG
DECLARE FUNCTION closesocket LIB "WS2_32.DLL" (BYVAL s AS LONG) AS LONG

FUNCTION PBMAIN() AS LONG
    PRINT "TCP Client via Winsock DECLARE:"
    PRINT "1. WSAStartup"
    PRINT "2. socket(AF_INET, SOCK_STREAM, 0) -> s"
    PRINT "3. connect(s, addr, addrlen)"
    PRINT "4. send(s, buf, len, 0)"
    PRINT "5. recv(s, buf, len, 0)"
    PRINT "6. closesocket(s) + WSACleanup"
    FUNCTION = 0
END FUNCTION
