Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.networking > #1521

Re: scatter/gather test

From Noob <root@127.0.0.1>
Newsgroups comp.os.linux.networking
Subject Re: scatter/gather test
Date 2012-07-18 15:38 +0200
Organization A noiseless patient Spider
Message-ID <ju6e96$jtk$1@dont-email.me> (permalink)
References <1e1274bf-aabe-48d3-b1cc-2fbcea2fc9c9@googlegroups.com> <ju4j27$lks$1@usenet01.boi.hp.com> <bd62df23-6ea9-4ed2-9781-f368c58ff97a@googlegroups.com> <ju61ug$e5e$1@dont-email.me> <fe427b4e-bbf6-4923-babd-2094e1589633@googlegroups.com>

Show all headers | View raw


[ Please, don't top-post ]

wkevin wrote:

> Noob wrote:
> 
>> Have you tried coalescing multiple disjoint buffers using sendmsg?
>> (sendmsg is the text-book API for user-space scatter/gather.)
>>
>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/sendmsg.html
>> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html
>>
>> ssize_t sendmsg(int socket, const struct msghdr *message, int flags);
>>
>> The msghdr structure shall include at least the following members:
>>
>> void          *msg_name        Optional address.
>> socklen_t      msg_namelen     Size of address.
>> struct iovec  *msg_iov         Scatter/gather array.
>> int            msg_iovlen      Members in msg_iov.
>> void          *msg_control     Ancillary data; see below.
>> socklen_t      msg_controllen  Ancillary data buffer len.
>> int            msg_flags       Flags on received message.
> 
> I started coding according to the sendmsg links.
> 
> Three more questions that might help me, if I may:
> 
> Should msg_iovlen for scatter gather case be greater than 1?
> this is what I think.

Right. sendmsg is supposed to coalesce ("gather") the data scattered
in the msg_iov[k].iov_base buffers.

POSIX states:
> The msg_iov and msg_iovlen fields of message specify zero or more
> buffers containing the data to be sent. msg_iov points to an array of
> iovec structures; msg_iovlen shall be set to the dimension of this
> array. In each iovec structure, the iov_base field specifies a
> storage area and the iov_len field gives its size in bytes. Some of
> these sizes can be zero. The data from each storage area indicated by
> msg_iov is sent in turn.

> and should msg_controllen be greater than 1?
> or msg_control can be NULL?

If you don't want to deal with all the complexity of sendmsg,
you can also use writev for connected sockets.

http://pubs.opengroup.org/onlinepubs/9699919799/functions/writev.html

> Will scatter gather work with this sendmsg API with UDP/TCP/RAW sockets,
> or in only one or two of them ?

I believe it's supposed to work with all types of sockets.

Regards.

Back to comp.os.linux.networking | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

scatter/gather test wkevin <wkevils@gmail.com> - 2012-07-17 11:37 -0700
  Re: scatter/gather test Rick Jones <rick.jones2@hp.com> - 2012-07-17 20:48 +0000
    Re: scatter/gather test wkevin <wkevils@gmail.com> - 2012-07-17 23:21 -0700
      Re: scatter/gather test Noob <root@127.0.0.1> - 2012-07-18 12:08 +0200
        Re: scatter/gather test wkevin <wkevils@gmail.com> - 2012-07-18 05:18 -0700
          Re: scatter/gather test Noob <root@127.0.0.1> - 2012-07-18 15:38 +0200
          Re: scatter/gather test Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-07-18 14:48 +0000
        Re: scatter/gather test wkevin <wkevils@gmail.com> - 2012-07-18 05:14 -0700
      Re: scatter/gather test Rick Jones <rick.jones2@hp.com> - 2012-07-18 18:55 +0000

csiph-web