Skip to content

Sending data and file descriptors at the same time #541

@chris-martin

Description

@chris-martin

From my brief experimentation with Wayland, it has seemed like the Wayland server expects that when you send a message with a file descriptor parameter, it expects the message and the fd to be sent together in a single sendmsg call. The network library presently does not have any explicit support for doing this.

Currently, in my own code I have a copy of NullSocketAddress, which is internally defined in the network package but not exported.

data NullSocketAddress = NullSocketAddress

instance SocketAddress NullSocketAddress where
    sizeOfSocketAddress _ = 0
    peekSocketAddress _ = return NullSocketAddress
    pokeSocketAddress _ _ = return ()

So then I can use sendBufMsg the way the network package does internally...

Network.Socket.Address.sendBufMsg socket NullSocketAddress datas controls mempty

... where datas contains the wayland message and controls contains the file descriptor.

Proposal one (nearly no effort): It would be nice if the network library simply exported the NullSocketAddress type so that I could use it instead of duplicating it.

Proposal two (slightly more work): Some explicit support for sending data and file descriptors in a single call?

sendWithFds :: Socket -> [ByteString] -> [Fd] -> IO ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions