1
// Copyright 2012 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
11
"golang.org/x/net/websocket"
14
// This example demonstrates a trivial client.
16
origin := "http://localhost/"
17
url := "ws://localhost:12345/ws"
18
ws, err := websocket.Dial(url, "", origin)
22
if _, err := ws.Write([]byte("hello, world!\n")); err != nil {
25
var msg = make([]byte, 512)
27
if n, err = ws.Read(msg); err != nil {
30
fmt.Printf("Received: %s.\n", msg[:n])