Created
February 13, 2018 04:29
-
-
Save syossan27/f71c434d45ccd3c29923cb1fa7051c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net" | |
"os" | |
) | |
func main() { | |
f := "/tmp/connection.sock" | |
defer os.Remove(f) | |
listener, err := net.Listen("unix", f) | |
if err != nil { | |
log.Fatalf("Error: %v\n", err) | |
} | |
for { | |
conn, err := listener.Accept() | |
if err != nil { | |
log.Fatalf("Error: %v\n", err) | |
os.Remove(f) | |
} | |
go func() { | |
defer conn.Close() | |
conn.Write([]byte("hoge")) | |
}() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment