# sockets

Associated topics:

/connect
  open a socket connection to a world
/dc
  close (disconnect) a socket
/fg
  bring a socket into the foreground
%login
  enable automatic login
/listsockets
  display a list of open sockets
fg_world()
  name of foreground world
idle()
  idle time
nactive()
  number of active sockets, or number of undisplayed lines
is_connected()
  tests whether a socket is connected
is_open()
  tests whether a socket is open
%background
  determines when to process text from background sockets
%bg_output
  determines how to display text from background sockets

A socket is a world-in-use, including a network connection (usually) and a virtual window for displaying text. TF can have multiple sockets open simultaneously. Only one of these can be displayed at a time; this is called the foreground socket. In visual mode, the name of the world on the foreground socket is displayed on the status line. Other sockets are in the background. Text from any socket is triggered and stored in history immediately, but is not displayed until that socket is brought into the foreground. Handling of events in background sockets can be customized with the %{bg_output} and %{background} flags.

The current socket is the socket to which commands are sent. The current socket is almost always the same as the foreground socket, except: 1) when a macro is triggered from any socket, that socket becomes the current socket for the duration of that macro execution; 2) when a /repeat or /quote with world redirection runs (-w option), that world's socket becomes the current socket for the duration of the process execution.

Text from a socket goes through a number of checks before being displayed. If the text matches any trigger patterns, a macro may be executed, or the text may be gagged or hilited. If the text was not gagged, TF also checks to see if it should be suppressed because of %quiet, /watchdog or /watchname. Finally, the text is added to the world's history and the global history, and is queued for display.

You can open a new socket in several ways:

- By giving the world name or address on the command line when starting tf.
- By using a /connect or /world command.
- By "bamfing" through a portal between muds (see "bamf").

You can switch between foreground sockets with the /fg command; the /dokey socketb and /dokey socketf commands, which by default are bound to ESC-left and ESC-right; and with the ESC-w keybinding, which switches to the next world with activity, or if there is none, to the last world you were on.

If the %{quitdone} flag is on, and you disconnect from all worlds (either with /dc or because the other end of the socket's network connection closes), TF will exit.

If the %{sockmload} flag is on, a world's macro file will be loaded when you switch to the socket for that world (either with the next and previous socket keys or with the /world command).

TF supports several TELNET options; see telnet.

If %{proxy_host} is defined, all connections will go through a proxy server. See: proxy.

Normally, certain types of disconnection can only be detected when you try to send something on a connection. TF uses the socket option SO_KEEPALIVE to detect such disconnections even when idle, but it usually takes at least 2 hours to detect. The time limit is usually a property of the operating system, and can not be set by TF or an unprivileged user.

A "connectionless" socket is created when you /connect to a world that does not have a host or port defined. If the world also has the echo flag set, any text you "send" to the socket is immediately "received", as if you were connected to an echo server.

See also: worlds

Back to index
Back to tf home page

Copyright © 1995, 1996, 1997, 1998, 1999, 2002, 2003, 2004 Ken Keys