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

net: ListenPacket does not support modifying socket options #22732

Closed
derek0377 opened this issue Nov 15, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@derek0377
Copy link

commented Nov 15, 2017

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

newest

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

linux

What did you do?

https://golang.org/pkg/net/#ListenPacket
this function may return a IPConn object through function ListenIP.

a IPConn object contains a socket object, the socket objects comes from src/net/sock_posix.go,function func socket(ctx context.Context and set socketopts through setDefaultSockopts function

https://github.com/golang/go/blob/master/src/net/sock_posix.go#L46

Here is the question: in my case I want to modify the socket's recv buffer size by

syscall.SetsockoptInt(s, syscall.SOL_SOCKET,syscall.SO_RCVBUF,1010241024)

but I can not find any fucntion in go-document to modify the socket's atrribute of the IPConn's socket, So i have to add code
syscall.SetsockoptInt(s, syscall.SOL_SOCKET,syscall.SO_RCVBUF,1010241024) at here:
https://github.com/golang/go/blob/master/src/net/sockopt_linux.go#L18

It is not good to modify the go source code,
Do you have a function which I can used to modify the IPConn's socket ? Thanks.
I think it is very useful to modify the socket's attribute such as recv buffer size,as the deafult
value can not satisfy every thing

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

What did you see instead?

@gbbr gbbr changed the title package net.dial,function ListenPacket's connection does not support modify socket's attribute net/dial: ListenPacket does not support modifying socket options Nov 15, 2017

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Nov 15, 2017

Closing as dup of #9661.

@mikioh

This comment has been minimized.

Copy link
Contributor

commented Nov 16, 2017

Here is the question: in my case I want to modify the socket's recv buffer size

c, err := net.ListenPacket("ip4:...", ...)
c.(*net.IPConn).SetReadBuffer(...)

Next time, please take a look at https://github.com/golang/go/wiki/Questions and ask your question on more appropriate forums.

@mikioh mikioh changed the title net/dial: ListenPacket does not support modifying socket options net: ListenPacket does not support modifying socket options Nov 16, 2017

@derek0377

This comment has been minimized.

Copy link
Author

commented Nov 16, 2017

@mikioh: Thanks a lot (∩_∩)

@golang golang locked and limited conversation to collaborators Nov 16, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.