PBXB64 Networking

TCP & UDP Standard

Full TCP and UDP networking with TCP OPEN/CLOSE/SEND/RECV/LISTEN/ACCEPT and UDP OPEN/CLOSE/SEND/RECV. Build servers, clients, and peer-to-peer applications. Real Win32 socket API (WSAStartup, socket, bind, listen, accept, send, recv).

TCP Client & Server

TCP client example
FUNCTION PBMAIN() AS LONG LOCAL hSocket AS LONG LOCAL buffer AS STRING LOCAL sent AS LONG ' Connect to server TCP OPEN "192.168.1.1" AS #1 PORT 8080 ' Send data TCP SEND #1, "Hello Server", sent ' Receive response TCP RECV #1, 1024, buffer PRINT "Server said: "; buffer TCP CLOSE #1 FUNCTION = 0 END FUNCTION

TCP OPEN creates a client connection. TCP SEND sends data with a sent-bytes count. TCP RECV receives up to a specified buffer size. TCP CLOSE releases the socket. TCP LISTEN/ACCEPT for server-side.

UDP - Connectionless

UDP send/receive
FUNCTION PBMAIN() AS LONG LOCAL buffer AS STRING LOCAL received AS LONG ' Open UDP socket UDP OPEN "0.0.0.0" AS #1 PORT 5000 ' Send to peer UDP SEND #1, "192.168.1.2", 5001, "Hello UDP!" ' Receive from any peer UDP RECV #1, 1024, received, buffer PRINT "Got: "; buffer UDP CLOSE #1 FUNCTION = 0 END FUNCTION

UDP is connectionless - each send specifies the destination address and port. UDP RECV returns the sender info and byte count. Ideal for discovery, streaming, and lightweight protocols.

HOST ADDR / HOST NAME

DNS resolution
FUNCTION PBMAIN() AS LONG LOCAL ip AS STRING LOCAL name AS STRING ip = HOST ADDR("smart-ai-robot.com") PRINT "IP: "; ip name = HOST NAME("192.168.1.1") PRINT "Name: "; name FUNCTION = 0 END FUNCTION

HOST ADDR resolves a hostname to IP address. HOST NAME performs reverse DNS lookup. Both use real gethostbyname/getaddrinfo Win32 APIs.

Back to feature list