[comp.databases] 'bug' program - useful for Client/Server Packages

matthew@CS.UCLA.EDU (Matthew Merzbacher) (10/01/89)

program should already have arrived on your system.  ++bsa]

The 'bug' program has been posted to comp.sources.misc.  'bug' listens on a
socket port and repeats everything it hears to another socket and to two files
(one for what one side of the socket says, the other for the other side).  

Why is this useful for databases?  Well, in particular, if you want to listen
to what Sybase clients say to Sybase servers at the lowest level, then you can 
use 'bug'.  In fact, that's what it was written for.  Here's how you do it:

1. Make two copies of your 'interfaces' file.  I'll call them 'oif' and 'nif'.
2. Leave 'oif' alone.  That's the original file for restoration purposes.
3. Edit 'nif' and change the QUERY port number to something unused.  You can
    change the other numbers as well, if you want to listen to those lines, but
    all the interesting stuff (for me) went down on QUERY.  You can use
    'netstat' to get a list of some used ports.
4. Now, start your server (if it isn't already going) using the original
    interface file.  Once it's going, replace the interface file that the 
    client uses (there's only one file on our system) with the 'nif' file.  Any
    client program will now try to connect to the 'nif' port instead of the
    correct server port.
5. On the client machine, run:
    "bug <nifport> <oifport> <servermachine> <fn1> <fn2>"
6. Run your client application (isql, db_library, dwb, whatever) 
7. Make sure you do something with the output of bug.  There isn't much, but
    you need to either look at it or redirect it.

This will create two or more files with the communication between the client
and the server.  If the bug process id is, say, 900, and it creates a child
with pid 950, the two files will be <fn1>.900.950 and <fn2>.900.950 .  Each
seperate connection creates a file (could be a fair number).

8. When you're done, kill 'bug' (CNTL-C or kill) and restore the 'oif' into the
    interface file

You'll want to use 'od -c' or 'od -cx' to view the output files.

Hours of fun!  Enjoy!  Comments/Questions to:

Matthew Merzbacher	ARPA:	matthew@CS.UCLA.EDU
Moo - Moo Moo  		UUCP:	...!{uunet|rutgers|ucbvax}!cs.ucla.edu!matthew
               		BONENET:	...!tibia%pelvis!matthew@jawbone