Open Tcp

Opens a TCP client connection and binds it to a file number.

Syntax
	KeyPgDeclareDeclare KeyPgFunctionFunction Open Tcp ( options KeyPgAsAs KeyPgStringString, As [#]filenumber KeyPgAsAs KeyPgLongLong 
	) KeyPgAsAs KeyPgLongLong

Usage
	result = Open Tcp( options[,] As [#]filenumber )
	Open Tcp options As [#]filenumber

Parameters
	options
		A comma-separated string describing the connection.
	filenumber
		The file number to bind to the connected socket.

Return Value
	Returns zero (0) on success, or a non-zero error code on failure.

Description
	Open Tcp connects to a TCP server and exposes the socket through 
	FreeBASIC's normal file I/O statements.  Once opened, the file number 
	can be used with KeyPgPrintPpPrint #, KeyPgLineinputPpLine Input #, KeyPgInputnumInput(), KeyPgGetfileioGet #, and KeyPgPutfileioPut #.

	The options string accepts:
		* host=name-or-address, required for client connections
		* port=number, required
		* timeout=milliseconds, optional socket timeout

	Unknown options are ignored so that future TCP options can be added 
	without breaking existing programs.

	For sockets, KeyPgEofEOF means that no byte is currently available to read.  Use 
	KeyPgEocEoc to test whether the peer has closed the connection.

Example
	See examples/network/opentcp/http-get.bas.

Platform Differences
	* TCP support is not available on all targets.  Programs that need to 
	  be portable should use target defines such as FB_DOS, FB_JS, and 
	  FB_XBOX where appropriate.

Differences from QB
	* New to FreeBASIC.

See also
	* KeyPgOpenTcpServerOpen Tcp Server
	* KeyPgTcpAcceptTcp Accept
	* KeyPgEocEoc
	* KeyPgOpenOpen

