Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // +build darwin dragonfly freebsd linux netbsd openbsd | |
|
estaab
2015/11/06 22:09:44
What does this line do?
dnj (Google)
2015/11/07 16:47:41
This makes it so that Go build will only include t
| |
| 6 | |
| 7 package streamclient | |
| 8 | |
| 9 import ( | |
| 10 "fmt" | |
| 11 "io" | |
| 12 "net" | |
| 13 "os" | |
| 14 ) | |
| 15 | |
| 16 // Register POSIX-only protocols. | |
| 17 func init() { | |
| 18 registerProtocol("unix", newUnixSocketClient) | |
| 19 } | |
| 20 | |
| 21 // newUnixSocketClient creates a new Client instance bound to a named pipe strea m | |
| 22 // server. | |
| 23 // | |
| 24 // newNPipeClient currently only works on POSIX (non-Windows) systems. | |
| 25 func newUnixSocketClient(path string) (Client, error) { | |
| 26 // Ensure that the supplied path exists and is a named pipe. | |
| 27 info, err := os.Lstat(path) | |
| 28 if err != nil { | |
| 29 return nil, fmt.Errorf("failed to stat file [%s]: %s", path, err ) | |
| 30 } | |
| 31 if info.Mode()&os.ModeSocket == 0 { | |
| 32 return nil, fmt.Errorf("not a named pipe: [%s]", path) | |
| 33 } | |
| 34 | |
| 35 return &clientImpl{func() (io.WriteCloser, error) { | |
| 36 return net.Dial("unix", path) | |
| 37 }}, nil | |
| 38 } | |
| OLD | NEW |