Implemented connection initialization function and data writing function