VARKON Version 1.17D 2003-03-25

| ## tcp_connect - function
Description
Connect to a specified server via TCP/IP and provide the id of the established socket connection. The id is used for successive operations (sending and receiving data). Always use TCP_close() to close the connection when session is over.
Syntax
tcp_connect(server, port, localport, socket );
STRING | server*132
INT | port
INT | localport
INT | socket
Principal parameters
server | - Server to connect, name or ip-adress ("servername" or "nnn.nnn.nnn.nnn").
port | - port number on server to connect.
localport | - local port number to use for connection,if =0, the system will choose a free port for you.
socket | - Integer to retrieve the id of the socket connection.
Optional parameters
none

Return value
An INT value equal to the current error status as below:

0 = | Operation was successful.
-3 = | The network subsystem or the associated service provider has failed.
-4 = | Winsock routine WSAstartup() failed. Could not initiate the use of WS2_32.DLL.
-5 = | Winsock routine socket() failed. A socket could not be opened.
-6 = | Local address/port already in use.
-7 = | The local address/port is not valid.
-8 = | Winsock routine bind() failed. Could not bind to specified local port.
-9 = | Can not resolve given host adress.
-10 = | The remote address is not a valid address.
-11 = | The attempt to connect was rejected.
-12 = | Winsock routine connect() failed. Could not connect.

Examples
`INT status; INT socket; status:=TCP_connect("COMP22", 5001, 0, socket);` We will connect to the computer "COMP22" on port 5001, our local port will be selected by the system. The id of the socket connection will be stored in the variable "socket".

See also
tcp_listen() tcp_close() tcp_outint() tcp_inint() tcp_outfloat() tcp_infloat() tcp_outvec() tcp_invec() tcp_getlocal() tcp_getremote()

VARKON Homepage | Index