Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

int nl_socket_set_buffer_size ( struct nl_sock *  sk,
int  rxbuf,
int  txbuf 
)

Set socket buffer size of netlink socket.

  • sk Netlink socket.
  • rxbuf New receive socket buffer size in bytes.
  • txbuf New transmit socket buffer size in bytes.
Sets the socket buffer size of a netlink socket to the specified values rxbuf and txbuf. Providing a value of 0 assumes a good default value.

Note:
It is not required to call this function prior to nl_connect().
Returns:
0 on sucess or a negative error code.

Definition at line 503 of file socket.c.

Referenced by nl_connect().

{
      int err;

      if (rxbuf <= 0)
            rxbuf = 32768;

      if (txbuf <= 0)
            txbuf = 32768;

      if (sk->s_fd == -1)
            return -NLE_BAD_SOCK;
      
      err = setsockopt(sk->s_fd, SOL_SOCKET, SO_SNDBUF,
                   &txbuf, sizeof(txbuf));
      if (err < 0)
            return -nl_syserr2nlerr(errno);

      err = setsockopt(sk->s_fd, SOL_SOCKET, SO_RCVBUF,
                   &rxbuf, sizeof(rxbuf));
      if (err < 0)
            return -nl_syserr2nlerr(errno);

      sk->s_flags |= NL_SOCK_BUFSIZE_SET;

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index