WebTcpipConnect Function

Action

Connects to any host on the Internet or intranet. sHost can be the domain name or the IP address. You can also use the predefined host name standardhost, which can be set in the Workbench. A URL cannot be used with WebTcpipConnect. This function must be used before any other call to WebTcpip functions.

Include file

WebAPI.bdh

Syntax

WebTcpipConnect( out hWeb          : number,
                 in  sHost         : string,
                 in  nPort         : number,
                 in  nSecurity     : number optional,
                 in  sLocalAddress : string optional ): boolean;

Return value

  • true if the function succeeds, and the function stores a valid handle in hWeb

  • false otherwise

Parameter Description
hWeb

Variable receiving a handle to the Web connection.

If this parameter contains a handle to a Web connection prior to the WebTcpipConnect function call, the memory allocated with the handle is released. Whenever you want to create a new Web connection, make sure this variable is initialized with 0 (this is automatically done within transactions when they are executed for the first time, but not within functions)

sHost Domain name or IP address, for example, "hostname.com" or "192.231.34.1"
nPort

Port to connect to. The following constants can be used as the standard port:

  • WEB_PORT_FTP

  • WEB_PORT_TELNET

  • WEB_PORT_SMTP

  • WEB_PORT_GOPHER

  • WEB_PORT_HTTP

  • WEB_PORT_HTTPS

  • WEB_PORT_POP3

  • WEB_PORT_NNTP

  • WEB_PORT_IRC

  • WEB_PORT_LDAP

  • WEB_PORT_LDAP_SSL

  • WEB_PORT_SOCKS

nSecurity

Specifies whether to establish a secure connection to the remote server (optional). Possible options are:

  • WEB_CONNECT_NONE. Establishes an insecure connection to the server (default)

  • WEB_CONNECT_SSL. Establishes a secure connection using SSL

sLocalAddress Specifies the local address and the port to which the socket should be bound (optional), for example, "192.168.70.101:4000".

Example

dcltrans
  transaction TWebApplevel
  var
    hWeb: number;
  begin
    WebTcpipConnect(hWeb, "standardhost", WEB_PORT_HTTP);
    WebTcpipShutdown(hWeb);
  end TWebApplevel;

Sample scripts

WebFileUpload01.bdf, WebMulti01.bdf, WebSecure01.bdf, WebTcpipHttp01.bdf, WebTcpipWebStone01.bdf