| // Copyright 2012 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| "code.google.com/p/go.net/websocket" |
| // This example demonstrates a trivial client. |
| origin := "http://localhost/" |
| url := "ws://localhost:12345/ws" |
| ws, err := websocket.Dial(url, "", origin) |
| if _, err := ws.Write([]byte("hello, world!\n")); err != nil { |
| var msg = make([]byte, 512) |
| if n, err = ws.Read(msg); err != nil { |
| fmt.Printf("Received: %s.\n", msg[:n]) |