Wrap socket bind and heartbeat thread in flet

A small DRY cleanup.