There is no free public WiFi provided in the port terminal or on the ship, other than the "free first 50MB" package offered on the ship's satellite system on most sailings. To take advantage of that, you must register by midnight on the day of departure, but you can use that data any time from initially boarding the ship until the final night of the sailing - it does not matter if the ship is still at the departure port, in a foreign port, or at sea in order to use the 50MB free.
As far as using any cellular data or text that you have on your mobile phone, tablet, or WiFi pocket hotspot without additional cost, you can do so as long as you still have signal from US land (assuming that you have service from the US), which can be quite awhile after you leave port. In an extreme example, if you are on the Fantasy on a Western Caribbean sailing from Port Canaveral and have a starboard cabin or go outside to the starboard 4th deck or up top, you can get the land-based signal from Florida all throughout the first night and into next morning. The ship's WiFi is always on, and the ship's cellular site will turn on once you're X miles from shore, but that doesn't mean you still can't get a land-based signal. For most phones, it should be obvious if you are roaming, as the current carrier is displayed on the screen. If it is anything other than what you normally see, then extra charges will apply. If your phone locks onto the ship's signal but you can still see the shore, try turning your phone off and back on again. It might have locked onto the ship's signal while inside when it couldn't see the land signal, but upon restart, it will prefer its home signal even if its weaker, as long as it can get it at all.