How do I use sockets (TCP or web)?

I am trying to add real time multiplayer support and I have a simple web socket (and tcp) server that just echoes what is sent. I have been looking for a long time know and I can’t seem to find any simple examples of how to open up a web/tcp socket and send/receive data in lua. Can anyone post any examples of using these?

V3.0 already bound websocket and xmlHttpRequest to lua. You can refer to testlua\extension\websocketTest and testlua\XmlHttpRequestTest.

but xmlHttpRequest to lua not very good, if you network error, you will not any response.