Support the sync API

Add methods `sync()` and `sync(t)` for `Connection`.