What are the procedures for sailing in and out of an international port?

What exactly is one supposed to do when arriving at an international sea port? I kind of doubt that you just sail in and tie up somewhere. Are there forms to fill out? Do you have to contact special people or pay certain fees?
2 answers 2