Program to talk to a network port

While the venerable telnet program can play the client side of a network connection, this program can play either the client or server side. In this example it is told to listen, then a web browser is sent to http://foobar.umd.edu:1069 and the query data from the browser is displayed. (A real masochist could actually type in a server response :-)...
% port -l
Listening on port 1069
(open)
GET / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows 98; DigExt)
Host: foobar.umd.edu:1069
Connection: Keep-Alive

^C
Depending on the operating system, it might be necessary to link a network library with this program. Here is an example Makefile stanza from Solaris:
port: port.c
        $(CC) port.c -lsocket -lnsl -o port

Back to ZBEN's home page.