声明不止,继续 go go go!!!
关于websocket,不会陌生。
之前也有博客介绍过golang中使用websocket,其中介绍了两个第三方库:
gorilla/websocket
nkovacs/go-socket.io
Go实战–golang中使用WebSocket实时聊天室(gorilla/websocket、nkovacs/go-socket.io)
所以,趁着介绍gorilla工具博客系列,今天就再重新介绍一下gorilla/websocket。
WebSocket
WebSocket是HTML5开始提供的一种浏览器与服务器间进行全双工通讯的网络技术。 WebSocket通信协议于2011年被IETF定为标准RFC 6455,WebSocketAPI被W3C定为标准。 在WebSocket API中,浏览器和服务器只需要要做一个握手的动作,然后,浏览器和服务器之间就形成了一条快速通道。两者之间就直接可以数据互相传送。
TCP: low-level, bi-directional, full-duplex, and guaranteed order transport layer. No browser support (except via plugin/Flash).
HTTP 1.0: request-response transport protocol layered on TCP. The client makes one full request, the server gives one full response, and then the connection is closed. The request methods (GET, POST, HEAD) have specific transactional meaning for resources on the server.
HTTP 1.1: maintains the request-response nature of HTTP 1.0, but allows the connection to stay open for multiple full requests/full responses (one response per request). Still has full headers in the request and response but the conne