I would use nodejs here is an example I found for tcp connections in nodejs: https://gist.github.com/tedmiston/5935757