It works now i added the ReadDeadline, thanks for the help :-)
Perry
On Wednesday, March 31, 2021 at 1:22:20 PM UTC+2 Brian Candler wrote:
> I think that in principle you are correct to perform your reads inside a
> goroutine, to allow them to be received asynchronously.
>
> If Read() blocks, i
I think that in principle you are correct to perform your reads inside a
goroutine, to allow them to be received asynchronously.
If Read() blocks, it's not a problem unless you want to shut down the
connection from the server side, and you can do that by setting a read
timeout which will unbloc
The protocol i am programming for sends a header of 8 bytes that contains a
body length.
My problem is dat c.Read(buf) is blocking. Can i read from the tcp
connection non blocking ?
On Wednesday, March 31, 2021 at 9:08:48 AM UTC+2 Brian Candler wrote:
> On Wednesday, 31 March 2021 at 04:13:12
On Wednesday, 31 March 2021 at 04:13:12 UTC+1 matt@gmail.com wrote:
> for i := 0; i > 5; i++ {
> // handle a single message
> n, err := c.Read(buf)
> if err == io.EOF {
> break
> }
> fmt.Fprintf(c, "Message Count %d, Data %s", i+1, buf[:n])
>
I will point out that
I am programming a binary protocol. The demo with telnet and the max of 5
messages was for testing this problem.
I need to be able send even when not recieving data. The program now works,
when de the client breaks the connection, there is no problem.
When de server stops the connection it some
Why are you using channels for this? I see some issues in the code, but
without knowing what you're actually trying to accomplish, it's hard to
give advice.
To do exactly what you described, I would simply change
handleDeviceConnection() to look similar to this:
func handleDeviceConnection(c net.
Hi,
I create a tcp server with goroutines.
When the tcp client closes the connection it workes.
After recieving 5 message from a telnet client it tries to close the
connection.
Some times it works, and sometimes not.
I create a smal demo : https://pastebin.com/raw/BjZWzLFq
This is my first tr