Tomakomai is the junction point for the JR Muroran, Hidaka and Chitose lines. The trip from Sapporo, via Chitose airport, takes about 45-60 min depending on train type.
Tomakomai is best known as a major port, with shipping services to points throughout Honshu. There are two separate terminals:
Tomakomai-ko Ferry Terminal (苫小牧港フェリーターミナル)
Tomakomai-ko East Ferry Terminal (苫小牧東港周文フェリーターミナル)
Both terminals are served by local buses from JR Tomakomai station (~20 min to either) and by long-distance buses direct from Sapporo (around 1:30).