Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why does conn.Write ignoring the number bytes written? #150

Open
kant777 opened this issue Mar 7, 2022 · 2 comments
Open

why does conn.Write ignoring the number bytes written? #150

kant777 opened this issue Mar 7, 2022 · 2 comments

Comments

@kant777
Copy link

kant777 commented Mar 7, 2022

Hi,

why does conn.Write ignoring the number bytes written here https://github.com/gobwas/ws/blob/master/write.go#L95 ? It seems to me that there is no guarantee net.Conn will write all the byes in one write call. if so, shouldn't the following function return both number of bytes and the error so the application can create ws continuation frames depending on the number of bytes written?

func WriteFrame(w io.Writer, f Frame) error {
	err := WriteHeader(w, f.Header)
	if err != nil {
		return err
	}
	_, err = w.Write(f.Payload)
	return err
}
@timo-klarshift
Copy link

while looking at the code I was wondering the same thing :)

@cristaloleg
Copy link
Collaborator

No idea why it's written that way, now it's like this for historical reasons (we don't plan 2.x for now).

As a fix we can compare n with f.Payload and if they don't match - return an error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants