So basically, I use WSARecv with this function from my client :
type Conn struct {
sd s.Handle
sa s.SockaddrInet4
}
func (c *Conn) Read(b []byte) (int, error) {
dataBuf := s.WSABuf{Len: uint32(len(b)), Buf: &b[0]}
flags := uint32(0)
qty := uint32(0)
err := s.WSARecv(c.sd, &dataBuf, 1, &qty, &flags, nil, nil)
return int(qty), err
}
Meanwhile the server is sending multiple packets (first one is 8 bytes, then they're all under 1000 bytes).
What happens is that WSARecv doesn't stop to read when the buffer b
is full. So I got an hard answer when It's taking too much memory :
Exception 0xc0000005 0x8 0xc08203195f 0xc08203195f PC=0xc08203195f syscall.Syscall9(0x7ff86cafe230, 0x7, 0x1f8, 0xc08200b5d0, 0x1, 0xc08200b5f0, 0xc08200b5e0, 0x0, 0x0, 0x0, ...) (dozen of lines like that)
And my program crash of course.
I wondered if my problem was about the way I use WSARecv or if I've to send back an aknowledgment every time I receive a packet.
NB : my server is under linux (and client under windows ofc).