| 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 package streamserver |
| 6 |
| 7 import ( |
| 8 "fmt" |
| 9 "net" |
| 10 |
| 11 log "github.com/luci/luci-go/common/logging" |
| 12 "golang.org/x/net/context" |
| 13 "gopkg.in/natefinch/npipe.v2" |
| 14 ) |
| 15 |
| 16 type namedPipeServer struct { |
| 17 namedPipeServerBase |
| 18 |
| 19 address string // The address of the Windows socket to create |
| 20 } |
| 21 |
| 22 // NewNamedPipeServer instantiates a new POSIX named pipe server instance. |
| 23 func NewNamedPipeServer(ctx context.Context, address string) StreamServer { |
| 24 s := &namedPipeServer{ |
| 25 address: address, |
| 26 } |
| 27 ctx = log.SetField(ctx, "address", address) |
| 28 s.initBase(ctx) |
| 29 return s |
| 30 } |
| 31 |
| 32 func (s *namedPipeServer) String() string { |
| 33 return fmt.Sprintf("NamedPipeServer[%s]", s.address) |
| 34 } |
| 35 |
| 36 // Wrapper around the "unix"-type Listener that cleans up the named pipe on |
| 37 // creation and 'Close()' |
| 38 type selfCleaningUNIXListener struct { |
| 39 path string |
| 40 listener net.Listener |
| 41 } |
| 42 |
| 43 // OS-specific override to create a UNIX named socket listener |
| 44 func (s *namedPipeServer) createListener() (net.Listener, error) { |
| 45 log.Debugf(s.ctx, "Creating Windows server socket Listener.") |
| 46 return npipe.Listen(s.address) |
| 47 } |
| OLD | NEW |