why not export syscall.recvmsg and syscall.sendmsg

245 views
Skip to first unread message

andrewh

unread,
Apr 23, 2014, 4:04:17 PM4/23/14
to golan...@googlegroups.com
Why is syscall such a tease?  syscall.Msghdr is exported but no real way to use it.

This really makes interfacing with non-network socket types a pain.  I guess cgo is the only way.  uggh.

andrewh

unread,
Apr 23, 2014, 6:01:25 PM4/23/14
to golan...@googlegroups.com
Nevermind.  I missed the oob param on the currently exported syscall.Sendmsg.   Thanks iant for pointing it out.

andrewh

unread,
Apr 23, 2014, 6:47:51 PM4/23/14
to golan...@googlegroups.com
Still not very friendly to use to construct your own SocketControlMessages.

Now if only syscall.cmsgData was exported... or better yet, a function that took []SocketControlMessage and returned a []byte

andrewh

unread,
Apr 23, 2014, 7:10:20 PM4/23/14
to golan...@googlegroups.com
It would also be nice if Sendmsg followed the same convention as sendmsg(2) and returned the number of bytes written (just in case).

Mikio Hara

unread,
Apr 23, 2014, 8:26:10 PM4/23/14
to andrewh, golang-nuts
On Thu, Apr 24, 2014 at 7:47 AM, andrewh <and...@spacemonkey.com> wrote:

> Still not very friendly to use to construct your own SocketControlMessages.

it's unfortunate but basically handling ancillary stuff is unfriendly.

> Now if only syscall.cmsgData was exported... or better yet, a function that
> took []SocketControlMessage and returned a []byte

instead, you can use syscall.CmsgLen and syscall.CmsgSpace. for example,
https://code.google.com/p/go/source/browse/ipv6/control_rfc3542_unix.go?repo=net#81

Mikio Hara

unread,
Apr 23, 2014, 8:28:10 PM4/23/14
to andrewh, golang-nuts
On Thu, Apr 24, 2014 at 8:10 AM, andrewh <and...@spacemonkey.com> wrote:

> It would also be nice if Sendmsg followed the same convention as sendmsg(2)
> and returned the number of bytes written (just in case).

it's a bug; see golang.org/issue/7645. go1.3 includes syscall.SendmsgN.
Reply all
Reply to author
Forward
0 new messages