~nskaggs/+junk/xenial-test

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/juju/sockets/sockets_nix.go

  • Committer: Nicholas Skaggs
  • Date: 2016-10-24 20:56:05 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161024205605-z8lta0uvuhtxwzwl
Initi with beta15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2014 Canonical Ltd.
 
2
// Copyright 2014 Cloudbase Solutions SRL
 
3
// Licensed under the AGPLv3, see LICENCE file for details.
 
4
 
 
5
// +build !windows
 
6
 
 
7
package sockets
 
8
 
 
9
import (
 
10
        "net"
 
11
        "net/rpc"
 
12
        "os"
 
13
 
 
14
        "github.com/juju/errors"
 
15
)
 
16
 
 
17
func Dial(socketPath string) (*rpc.Client, error) {
 
18
        return rpc.Dial("unix", socketPath)
 
19
}
 
20
 
 
21
func Listen(socketPath string) (net.Listener, error) {
 
22
        // In case the unix socket is present, delete it.
 
23
        if err := os.Remove(socketPath); err != nil {
 
24
                logger.Tracef("ignoring error on removing %q: %v", socketPath, err)
 
25
        }
 
26
        listener, err := net.Listen("unix", socketPath)
 
27
        return listener, errors.Trace(err)
 
28
}