use tcp sockets on windows

Mentioned in #12.
This commit is contained in:
Gokcehan committed 2017-07-23 17:14:50 +03:00
1 parent cb072eba12
commit e654700bd2
3 files changed
+14 -6

No files matched your search

+4 -4
View File
@@ -33,7 +33,7 @@ func client() {
var serverChan <-chan expr
c, err := net.Dial("unix", gSocketPath)
c, err := net.Dial(gSocketProt, gSocketPath)
if err != nil {
msg := fmt.Sprintf("connecting server: %s", err)
app.ui.message = msg
@@ -97,7 +97,7 @@ func readExpr(c net.Conn) <-chan expr {
}
func saveFiles(list []string, copy bool) error {
c, err := net.Dial("unix", gSocketPath)
c, err := net.Dial(gSocketProt, gSocketPath)
if err != nil {
return fmt.Errorf("dialing to save files: %s", err)
}
@@ -119,7 +119,7 @@ func saveFiles(list []string, copy bool) error {
}
func loadFiles() (list []string, copy bool, err error) {
c, e := net.Dial("unix", gSocketPath)
c, e := net.Dial(gSocketProt, gSocketPath)
if e != nil {
err = fmt.Errorf("dialing to load files: %s", e)
return
@@ -158,7 +158,7 @@ func loadFiles() (list []string, copy bool, err error) {
}
func sendRemote(cmd string) error {
c, err := net.Dial("unix", gSocketPath)
c, err := net.Dial(gSocketProt, gSocketPath)
if err != nil {
return fmt.Errorf("dialing to send server: %s", err)
}
+9 -1
View File
@@ -7,6 +7,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"runtime/pprof"
)
@@ -22,6 +23,7 @@ var (
gClientID int
gLastDirPath string
gSelectionPath string
gSocketProt string
gSocketPath string
gLogPath string
gServerLogPath string
@@ -48,7 +50,13 @@ func init() {
tmp := os.TempDir()
gSocketPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.sock", envUser))
if runtime.GOOS == "windows" {
gSocketProt = "tcp"
gSocketPath = ":12345"
} else {
gSocketProt = "unix"
gSocketPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.sock", envUser))
}
gClientID = 1000
gLogPath = filepath.Join(tmp, fmt.Sprintf("lf.%s.%d.log", envUser, gClientID))
+1 -1
View File
@@ -26,7 +26,7 @@ func serve() {
log.Print("hi!")
l, err := net.Listen("unix", gSocketPath)
l, err := net.Listen(gSocketProt, gSocketPath)
if err != nil {
log.Printf("listening socket: %s", err)
return