Using TCP sockets
TCP communication forms the basis of modern networking, so it is no surprise that we will start with it. The basic Tcl command to use in this topic is socket
, and it is built into the Tcl interpreter core. A socket is an abstract term representing the endpoint of a bidirectional connection across the network. In this chapter, we will often use the terms socket and channel interchangeably, although the channel term is more general (not every channel is a socket, but every socket is a channel). We do this because the execution of socket
will result in using channels—the effect of executing this command is usually opening the connection over the TCP protocol (socket supports only TCP) and returning a channel identifier, which may be used for sending or receiving data through that newly created channel, in terms of commands like read
or puts
. The command may be used in two flavors in order to create client-side or server-side sockets.
Client sockets serve as the connection...