TCP Client/gateway/server written in C