You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
type masterProcessSlave struct {
conn net.Conn
}
func (sc *masterProcessSlave) ProcessSlaveMsg() {
if sc.conn != nil {
br := bufio.NewReader(sc.conn)
dec := json.NewDecoder(br)
var exit bool
for {
if exit {
break
}
var content Message
err := dec.Decode(&content)
if err != nil {
fmt.Println(err)
panic(sc.SlaveLabel + " lost connected")
}
fmt.Println(content)
}
}
}
func masterProcessSlave(listen net.Listener) {
for {
client, err := listen.Accept()
if err != nil {
panic(err)
}
slave := tcp.NewMasterProcessSlave(client)
go slave.ProcessSlaveMsg()
}
}
func (s *SlaveProcessMaster) SendMsgToMaster(no MsgNo, data []byte) {
if s.conn != nil {
req := &Message{MsgNo: no, Data: data}
bytes, err := json.Marshal(req)
if err != nil {
panic(errstd.JsonSerializerErr)
}
_, errTcp := s.conn.Write(bytes)
if errTcp != nil {
fmt.Printf("send master err %v", errTcp)
panic(errstd.CommunicationErr)
}
}
}
What did you see happen?
Use the net package of the Go language to perform inter-process TCP communication. The receiving-end page terminal reports EOF, and the sending-end process experiences coredump. The stack information is as follows. The IP address used for communication is 127.0.0.1.
(gdb) bt
#0 0x0000000000572350 in net.init () at /usr/local/go/src/net/addrselect.go:231 #1 0x00007fc8c8709c58 in ?? () #2 0x00007ffd24f38d90 in ?? () #3 0x0000000000465361 in runtime.name.name (n=..., ~r0=...) at /usr/local/go/src/runtime/type.go:459 #4 0x00007fc8c8709c20 in ?? () #5 0x0000000000000000 in ?? ()
What did you expect to see?
The service is normal.
The text was updated successfully, but these errors were encountered:
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
Go version
go version go1.20.4 linux/amd64
Output of
go env
in your module/workspace:What did you do?
进程间正常 tcp 通信
What did you see happen?
Use the net package of the Go language to perform inter-process TCP communication. The receiving-end page terminal reports EOF, and the sending-end process experiences coredump. The stack information is as follows. The IP address used for communication is 127.0.0.1.
(gdb) bt
#0 0x0000000000572350 in net.init () at /usr/local/go/src/net/addrselect.go:231
#1 0x00007fc8c8709c58 in ?? ()
#2 0x00007ffd24f38d90 in ?? ()
#3 0x0000000000465361 in runtime.name.name (n=..., ~r0=...) at /usr/local/go/src/runtime/type.go:459
#4 0x00007fc8c8709c20 in ?? ()
#5 0x0000000000000000 in ?? ()
What did you expect to see?
The service is normal.
The text was updated successfully, but these errors were encountered: