Closed parsibox closed 6 months ago
Basically you can just repeat these lines in the example. https://github.com/wmnsk/go-sccp/blob/1c9ff26fff8eae91573d45a0a7a0817544f3dc4d/examples/client/simple-client.go#L46-L73
and after that load balancer also work? only this?
Do you mean traffic mode type = load share? Such behavior is not built in, and users need to handle each m3ua.Conn
as they want.
Yes, that's exactly what I meant ok if we have 2 m3ua link can we detect which of them dead or have error? i think we only detect this when we call m3conn.Write and get error , is this correct?
and dear in client how can we receive incoming packet from each m3ua link? i think we need create listener, err := m3ua.Listen("m3ua", laddr, config) for each m3ua link , is this correct?
You'll need to monitor the Conn continuously, typically by calling Read
in a for
clause. If the link is closed or dead by some error the Read
returns error. Write
, on the other hand, is occasionally called when you need to send something (outgoing requests or replies to incoming requests). I think this answers both of your questions.
Tip: The Conn
is implemented in similar way to other type of Conn
in Go (TCP, UDP, etc.). I think it's nice for you to search how to implement a simple TCP/UDP client/server in Go first to learn the conventions.
thanks If you could add an example to the repository, it would be great, it would probably help other people a lot Thank you for your patience in answering
i found this for reading
func serve(conn *m3ua.Conn) {
defer conn.Close()
buf := make([]byte, 1500)
for {
n, err := conn.Read(buf)
if err != nil {
// this indicates the conn is no longer alive. close M3UA conn and wait for INIT again.
if err == io.EOF {
log.Printf("Closed M3UA conn with: %s, waiting to come back...", conn.RemoteAddr())
return
}
// this indicates some unexpected error occurred on M3UA conn.
log.Printf("Error reading from M3UA conn: %s", err)
return
}
log.Printf("Read: %x", buf[:n])
}
}
hi can we connect to multiple m3ua link? can you add an example for it?