Skip to content

deadline causes instant disconnection #1

@matjam

Description

@matjam

Setting the deadline here:

c.SetReadDeadline(time.Now().Add(time.Microsecond))

Seems to cause issues if you try to do something like this:

func telnetHandler(c *telnet.Connection) {
	log.Printf("Connection received: %s", c.RemoteAddr())
	c.Write([]byte("Connected!\r\n"))

	var b []byte = make([]byte, 1)
	for {
		log.Println("reading a byte")
		_, err := c.Read(b)
		if err != nil {
			log.Error("error reading from telnet client: ", err)
			log.Error("closing socket")
			return
		}
		log.Println("character received: ", string(b))
	}
}

For my application, I need to read 1 character at a time and the deadline code seems to time out the Read(). Removing the deadline resolves the issue for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions