There are several function which manage the input MIDI message buffer:
MidiInPort objects link to an array of hardware MIDI input ports. These ports can be open/closed. Also if open, these ports can be paused or unpaused with the pause/unpause functions. If the port is closed, then no MIDI messages will be read from the port by the lower level MIDI driver of the operating system. If the port is open and unpaused, then the MIDI input driver of the operating system will insert messages into the objects MIDI message buffer. If the object's port is open but paused, then there will be no messages inserted into the MIDI buffer as they come into the computer.
The port to which a MidiInPort object can be attached to can change after being assigned to a port. Use the setPort function to change ports. The getNumPorts function will return how many valid ports are available in the input port array; you must set to a valid port number. Once the object has selected a port, then the port may be opened with the open function. Opening a port which is already opened is not an error since the MidiInPorts keep track of when a port is open/closed, and will not reopen an opened port, nor reclose a closed port.