Accepted answer, need to update reput and use sockets