SOCKET_CONNECT Function
Connects to a socket at a given host and port.
Usage
connection = SOCKET_CONNECT(host, port)
Input Parameters
host—A string specifying the host name or IP address of the server machine (the machine that the client will connect to).
port—A long integer specifying the port number to connect to on the server machine.
Keywords
None.
Returned Value
connection—On success, returns a socket handle for the connection; on failure, returns one of the following values:
–1—Unable to get host address.
–2—Could not connect to socket.
Discussion
The host parameter can be an IP address number, a DNS name, or any other valid address designation (such as, localhost).
It is good practice to close the socket connection when you are finished with it.
Example
The host must be a valid IP address. For example:
connection=SOCKET_CONNECT('www.vni.com', 80)
; Uses a DNS name for the host.
connection=SOCKET_CONNECT('192.130.240.125', 1500)
; Uses an IP address number for the host.
connection=SOCKET_CONNECT('localhost', 1500)
; Uses the local loopback address for the host.
connection=SOCKET_CONNECT('mymachine', 2100)
; Uses a local network designation for the host.
See Also
For more detailed information on using the socket routines, see the PV‑WAVE Application Developer’s Guide.
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.