Internet Controls

The Internet tab provides 9 controls for web browsing, HTTP/FTP networking, email, WebSocket communication, and TCP/UDP socket programming. All controls are cross-platform and use non-blocking I/O internally.

TWebView CT_WEBVIEW = 62

Embeds a full web browser inside a form. Renders HTML content or navigates to URLs using the platform's native web engine.

PropertyTypeDefaultDescription
cURLString""URL to navigate to
cHTMLString""Raw HTML content to render
lCanGoBackLogical.F.Whether navigation history allows going back (read-only)
lCanGoForwardLogical.F.Whether navigation history allows going forward (read-only)
cTitleString""Page title (read-only)
EventCategoryDescription
OnNavigateNavigationFired before navigating to a new URL. Return .F. to cancel
OnLoadNavigationPage finished loading
OnErrorErrorNavigation or rendering error occurred
PlatformNative Widget
WindowsWebView2 (Chromium-based Edge)
macOSWKWebView (WebKit)
LinuxWebKitGTK (WebKit2)

TWebServer CT_WEBSERVER = 71

Embedded HTTP/HTTPS server. Allows your application to serve web pages, REST APIs, or act as a local service endpoint.

PropertyTypeDefaultDescription
nPortNumeric8080Listening port number
cHostString"0.0.0.0"Bind address
cDocumentRootString""Root directory for static files
lSSLLogical.F.Enable HTTPS
cCertFileString""Path to SSL certificate file
cKeyFileString""Path to SSL private key file
nMaxConnectionsNumeric256Maximum simultaneous connections
EventCategoryDescription
OnRequestActionHTTP request received. Params: oRequest, oResponse
OnConnectConnectionNew client connected
OnDisconnectConnectionClient disconnected
OnStartLifecycleServer started listening
OnStopLifecycleServer stopped
OnErrorErrorServer error occurred

TWebSocket CT_WEBSOCKET = 72

WebSocket client for real-time bidirectional communication with a server.

PropertyTypeDefaultDescription
cURLString""WebSocket server URL (ws:// or wss://)
cProtocolString""Sub-protocol to negotiate
lAutoReconnectLogical.F.Automatically reconnect on disconnection
nReconnectDelayNumeric3000Delay in ms before reconnect attempt
EventCategoryDescription
OnOpenConnectionConnection established
OnMessageDataMessage received from server
OnCloseConnectionConnection closed
OnErrorErrorConnection or protocol error

THttpClient CT_HTTPCLIENT = 73

HTTP client for making REST API calls, downloading files, and general HTTP communication.

PropertyTypeDefaultDescription
cURLString""Request URL
cMethodString"GET"HTTP method (GET, POST, PUT, DELETE, PATCH)
aHeadersArray{}Request headers as key-value pairs
cBodyString""Request body content
nTimeoutNumeric30000Request timeout in milliseconds
nStatusCodeNumeric0Response status code (read-only)
EventCategoryDescription
OnResponseDataResponse received. Params: nStatus, cBody, aHeaders
OnProgressDataDownload/upload progress. Params: nCurrent, nTotal
OnErrorErrorRequest failed

TFtpClient CT_FTPCLIENT = 74

FTP/FTPS client for file transfer operations.

PropertyTypeDefaultDescription
cHostString""FTP server hostname
nPortNumeric21Server port
cUserString""Login username
cPasswordString""Login password
lPassiveModeLogical.T.Use passive mode for data transfers
lSSLLogical.F.Use FTPS (FTP over TLS)
EventCategoryDescription
OnConnectConnectionSuccessfully connected to server
OnTransferDataFile transfer progress. Params: cFile, nBytes, nTotal
OnErrorErrorConnection or transfer error

TSmtpClient CT_SMTPCLIENT = 75

SMTP client for sending email messages with attachments.

PropertyTypeDefaultDescription
cHostString""SMTP server hostname
nPortNumeric587Server port (25, 465, or 587)
lSSLLogical.T.Use TLS/SSL encryption
cUserString""Authentication username
cPasswordString""Authentication password
cFromString""Sender email address
cToString""Recipient email address(es), comma-separated
cSubjectString""Email subject line
cBodyString""Email body content
EventCategoryDescription
OnSendActionEmail sent successfully
OnErrorErrorSend or connection error

TTcpServer CT_TCPSERVER = 76

TCP socket server. Listens for incoming connections and manages multiple clients.

PropertyTypeDefaultDescription
nPortNumeric0Listening port
cHostString"0.0.0.0"Bind address
nMaxConnectionsNumeric128Maximum simultaneous connections
lActiveLogical.F.Server is currently listening (read-only)
EventCategoryDescription
OnAcceptConnectionNew client connection accepted. Params: oClient
OnReceiveDataData received from client. Params: oClient, cData
OnDisconnectConnectionClient disconnected. Params: oClient

TTcpClient CT_TCPCLIENT = 77

TCP socket client. Connects to a remote server for stream-based communication.

PropertyTypeDefaultDescription
cHostString""Remote server hostname or IP
nPortNumeric0Remote server port
nTimeoutNumeric10000Connection timeout in milliseconds
lConnectedLogical.F.Connection status (read-only)
EventCategoryDescription
OnConnectConnectionSuccessfully connected to server
OnReceiveDataData received from server. Params: cData
OnDisconnectConnectionDisconnected from server

TUdpSocket CT_UDPSOCKET = 78

UDP datagram socket for connectionless, low-latency communication.

PropertyTypeDefaultDescription
nPortNumeric0Local port to bind to
lBroadcastLogical.F.Enable broadcast mode
cHostString"0.0.0.0"Bind address
EventCategoryDescription
OnReceiveDataDatagram received. Params: cData, cSenderIP, nSenderPort

Code Example: Simple Web Server

// A simple web server that responds to HTTP requests

FUNCTION Main()

   LOCAL oServer

   oServer := TWebServer():New()
   oServer:nPort := 8080
   oServer:cDocumentRoot := "./public"

   oServer:OnRequest := { |oReq, oRes| HandleRequest( oReq, oRes ) }
   oServer:OnStart   := { || QOut( "Server running on port 8080" ) }
   oServer:OnError   := { |e| QOut( "Error: " + e:Description ) }

   oServer:Start()

   // Keep the application running
   WAIT "Press any key to stop..."

   oServer:Stop()

RETURN NIL

FUNCTION HandleRequest( oReq, oRes )

   DO CASE
      CASE oReq:cPath == "/api/hello"
         oRes:cContentType := "application/json"
         oRes:cBody := '{"message": "Hello from HarbourBuilder!"}'

      CASE oReq:cPath == "/api/time"
         oRes:cContentType := "application/json"
         oRes:cBody := '{"time": "' + Time() + '"}'

      OTHERWISE
         oRes:nStatus := 404
         oRes:cBody := "Not Found"
   ENDCASE

RETURN NIL
9 Internet Controls

All Internet controls use asynchronous, event-driven I/O. Network operations never block the UI thread. TLS/SSL is supported on all platforms using the system's native certificate store.

On This Page

TWebView CT_WEBVIEW = 62 TWebServer CT_WEBSERVER = 71 TWebSocket CT_WEBSOCKET = 72 THttpClient CT_HTTPCLIENT = 73 TFtpClient CT_FTPCLIENT = 74 TSmtpClient CT_SMTPCLIENT = 75 TTcpServer CT_TCPSERVER = 76 TTcpClient CT_TCPCLIENT = 77 TUdpSocket CT_UDPSOCKET = 78 Code Example: Simple Web Server