Unix Sockets in Go

mohsen khashei via sr-users <[email protected]>
Newsgroups gmane.comp.voip.ser
Message-ID <CALC6B6HJQzwwJPPDVboFO35CQa_cBHzQMAZDCmd2o0ndnL1nEw@mail.gmail.com>
Hi I want to run rpc commands like permissions.addressReload from a go
application but with no luck please help me my code is:


cmd:="permissions.addressReload"
conn, err := net.Dial("unix", "/run/kamailio/kamailio_ctl")
if err != nil {
return "", fmt.Errorf("connect error: %w", err)
}
defer conn.Close()

// _, err = fmt.Fprintf(conn, "%s\n", cmd)
 _, err = conn.Write([]byte(cmd))
 if err != nil {
     return "", fmt.Errorf("write error: %w", err)
 }

 scanner := bufio.NewScanner(conn)
 var output string
 for scanner.Scan() {
     output += scanner.Text() + "\n"
 }
 if err := scanner.Err(); err != nil {
     return "", fmt.Errorf("read error: %w", err)
 }

`
the only thing i get is:
¡0#^@ ^A<90><91>^^bad request: corrupted packet^@

__________________________________________________________
Kamailio - Users Mailing List - Non Commercial Discussions -- [email protected]
To unsubscribe send an email to [email protected]
Important: keep the mailing list in the recipients, do not reply only to the sender!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.