Skip to content

ResponseTimeout is not configurable on per message basis #43

@kulak

Description

@kulak

ResponseTimeout const control message response timeout and it is set to 2 seconds.

While 2 seconds timeout is ok for 1st message, when message is re transmitted the timeout value needs to be increased. Thus, we need to be able to supply custom ResponseTimeout with the request data as it appears to be a higher level function in this API design.

const (
	// ResponseTimeout is the amount of time to wait for a
	// response.
	ResponseTimeout = time.Second * 2
)

// Receive a message.
func Receive(l *net.UDPConn, buf []byte) (Message, error) {
	l.SetReadDeadline(time.Now().Add(ResponseTimeout))

	nr, _, err := l.ReadFromUDP(buf)
	if err != nil {
		return Message{}, err
	}
	return parseMessage(buf[:nr])
}

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