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