IBM Research

Miscellaneous tools

Created: 11.9.97
Modified:
Contents:
  1. TCP tools
  2. Atomic operations
  3. Background command shell
  4. Clock utilities
  5. Shared memory allocator

1. TCP tools

The command tcptalk is equivalent to telnet when used as a client. It also runs as a server, serving one client at a time.

The command getpeer expects a socket as its stdin, and prints out the peer IP address and port numbers. It is simply a command line equivalent for the getpeername socket library function. It works with both TCP and UDP sockets.

Both HTTP and RTSP use a zero-length line, ie. one matching /^$/, to demarkate the data from the request or response header fields. This can be correctly handled in perl or a stream editor like awk or sed, but not by a shell. The command getparams echos stdin to stdout until it hits a zero-length line, and can be used to parse HTTP and RTSP messages. It understands and silently deletes carriage-returns.

The tool crlf echos stdin to stdout, inserting carriage-returns appropriately. It is to be used only when outputting a text file. In our RTSP server, it is used to output the $Out file generated by the application do_method functions (see the server API).


2. Atomic operations

This is useful for counting visitors, generating sequence numbers and performing semaphore operations the old fashioned way. It atomically increments a single integer in a file.
Usage:
	atomic file [+-] [delta]
Note that the Unix semaphores can be directly used in perl, as well as by invoking the syscall command.


3. Background command shell

Unlike my ksh-based quickie, most Web servers are too intelligent and will wait for the slowest background process to complete before returning a reply. This is particularly unhealthy for a CGI-driven media control, because a response to a CGI play command will not return until the media has been fully played. The only way to decouple the background playback from the Web response is to delegate playback to an entirely independent process.

Upsh creates a Unix domain socket pipe and executes shell commands received on that pipe. CGI programs echo the background shell commands to the pipe using upsend. The approach is Unix-friendly, portable (works on BSD, System V and other flavors without ado), and can be adequately secured, because the commands do not go on the network and the pipe is protected by Unix permissions.


4. Clock utilities

The utf command converts local or GMT time in UTC format to time_t and vice versa. It can be also used to tell the current time in either format.

The command hmsadd adds command line time arguments in HH.MM.SS format and prints the result.

The two tools are generally sufficient for performing time conversions in the RTSP server application interface (see API). See also the Utime class in the Real Time Scheduler library, which can be used to move the time conversions to C/C++ code.


[ Research home page | IBM home page | Search | ContactIBM | Legal | Author ]