Skip to content

Instantly share code, notes, and snippets.

@Gilgames000
Created December 29, 2019 17:14
Show Gist options
  • Save Gilgames000/dbdacd1f455aff60d819ffdddd3dfd02 to your computer and use it in GitHub Desktop.
Save Gilgames000/dbdacd1f455aff60d819ffdddd3dfd02 to your computer and use it in GitHub Desktop.
NosTale packet sender pipe server example
package main
import (
"bufio"
"fmt"
"os"
"strings"
"gopkg.in/natefinch/npipe.v2"
)
func main() {
ln, err := npipe.Listen(`\\.\pipe\nt_snd_42`)
if err != nil {
fmt.Println(err)
os.Exit(2)
}
fmt.Println("Pipe server started")
conn, err := ln.Accept()
if err != nil {
fmt.Println(err)
os.Exit(2)
}
fmt.Println("Client connected")
reader := bufio.NewReader(os.Stdin)
for {
fmt.Print("Message: ")
msg, _ := reader.ReadString('\n')
msg = strings.TrimRight(msg, "\r\n")
n, _ := conn.Write([]byte(msg))
fmt.Println("Bytes sent:", n)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment