[ Up (Contents) ] Page Last Updated: 13 April 1998

Appendix D

"Listening" and "Talking" at a TCP/IP Port

Alternate Formats
This Appendix (Word 6 Format)

Related Content
backtalk.c (Source code)  |  listen.c (Source code)

This appendix describes the programs listen.c. and backtalk.c. Listen.c is a simple program that listens at a TCP/IP port and prints to the display any characters received at the port. Thus, listen can be used to observe the data that Web browsers send when making an HTTP request. Similar to listen, backtalk listens at a TCP/IP port and prints to the display any characters received at the port. However, backtalk also lets the user type characters (enter data) at the display, such that these characters are sent on to the remote program that is talking to that port. Thus, backtalk can act like a simpleminded HTTP server--or rather, the user and backtalk can act like a simpleminded server, since the user has to type, by hand, the data to be returned to the browser. With backtalk, CTRL-D marks the end of a transmission without terminating the program, so you must end your typed message with this character. For both backtalk and listen, CTRL-C ends the transmission and kills the program.

To run either program, simply type the program name at the command prompt. Listen (or backtalk) then prints the port number it is listening at, and goes silent. Here is a typical example (the typed command is shown in boldface):

    

prompt%> listen

listening on 2055

At this point, any data sent to port 2055 on this computer will be printed on the screen just below the string listening on 2055. For example, if the preceding command were executed on the machine www.testing.org, then a browser could be "pointed" to the running listen program simply by accessing the URL
    

www.testing.org:2055/test/path 

so that the browser contacts the machine www.testing.org at port 2055.With backtalk, any characters typed to the screen by the user are sent to the remote client process attached to this port. The program is terminated by typing CTRL-C.

Where to Obtain the Programs

The source code is available from this Web site, at:
backtalk.c and listen.c.


The HTML 4.0 Sourcebook © 1995-1998 by Ian S. Graham