# Using multiple consoles

### Why?

Using more than one console can be useful if you want to issue a command during the simulated program is executed.

### How?

To get multiple consoles you have to execute the simulator in the background like daemons run in UNIX systems. The simulator then will listen and wait for network connection requests and provide console functions for network connections.

To run µCsim in the background you have to use -Z option for the simulator:

    pigmy$ s51 -Z 5555 foo.hex

In this case s51 runs in foreground in your command interpreters point of view. Of course you can run the program really in the background:

    pigmy$ s51 -Z 5555 foo.hex &

The parameter of the -Z option is a port number. This can be number of any unused port of your machine. If the specified port is already occupied then following message appears:

    pigmy$ s51 -Z 5555
    bind: Address already in use

In this case you have to use an other number.

Let's suppose you have found a free port number and the simulator listens on it. Now go to somewhere else, at least to an other window and connect to the simulator:

    other_machine$ telnet pigmy 5555

First parameter to the telnet command is the name of the machine where the simulator is running on. It can be `localhost` if you are on the same machine or the fully qualified host name if you are at the other end of the world. Second parameter is the number of the port where the simulator is listening. It must be the same number which was specified as parameter of the -Z option when the simulator was started (see above).

Connecting to the simulator you get a command console:

    pigmy$ telnet pigmy 5555
    Trying 127.0.0.1...
    Connected to pigmy.talker.bt.
    Escape character is '^]'.
    ucsim 0.2.21, Copyright (C) 1997 Daniel Drotos, Talker Bt.
    ucsim comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.
    >

### What to do with it?

Obviously you can telnet into the simulator as many times as many command consoles you want. You can start the execution using one console and while the program is executed you can, for example, modify ports on the other console.

### Stop

Using quit (q) command you can not stop the simulator. It just stops the actual console and the simulator continues to listen for incoming network connections.

To stop the simulator completely you have to use kill command. Note that if you stop the simulator then all the active network connections (all other consoles) will stop.

### Tricks

You can get a console on the terminal where you started the simulator. To do this you must explicitly ask the simulator to open a console on the standard input/output. You can do this using -c option and specify the actual terminal as parameter for it:

    pigmy$ s51 -Z 5555 foo.hex -c /dev/tty