add function for socket channel and do unit test for it