*	open a TCP connection (text only) for CSNOBOL4
*	Phil Budne <phil@ultimate.com>
*	May 7, 1997
*	$Id: tcp.sno,v 1.4 2020-11-27 02:47:44 phil Exp $

****************
*	map I/O variable name to unit

	TCP.UNITS = TABLE()

****************
*	open a TCP connection

	DEFINE("TCP.OPEN(TCP.NAME,TCP.HOST,TCP.PORT,TCP.MODE,TCP.TLS)UNIT")
							:(TCP.OPEN.END)
TCP.OPEN
	UNIT = IO_FINDUNIT()
	INPUT(TCP.NAME, UNIT, "U" TCP.MODE,
+			(DIFFER(TCP.TLS) "/tls/", "/tcp/")
+			 TCP.HOST "/" TCP.PORT)		:F(FRETURN)
	OUTPUT(TCP.NAME, UNIT)
	TCP.UNITS[TCP.NAME] = UNIT			:(RETURN)
TCP.OPEN.END

****************
*	close a TCP connection

	DEFINE("TCP.CLOSE(TCP.NAME)")			:(TCP.CLOSE.END)
TCP.CLOSE
	ENDFILE(TCP.UNITS[TCP.NAME])			:F(FRETURN)
	TCP.UNITS[TCP.NAME] =
	DETACH(TCP.NAME)				:(RETURN)
TCP.CLOSE.END
