Client Sockets

A client opens a socket by specifying the host address and port number for the server of the socket. The host address gives the network location (i.e., which computer), and the port selects a particular server from all the possible servers that may be running on that host. For example, HTTP servers typically use port 80, while FTP servers use port 20. The following example shows how to open a client socket to a Web server:

set s [socket www.scriptics.com 80]

There are two forms for host names. The previous example uses a domain name: www.scriptics.com. You can also specify raw IP addresses, which are specified with four dot-separated integers (e.g., 128.15.115.32). A domain name is mapped into a raw IP address by the system software, ...

Get Practical Programming in Tcl & Tk, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.