2 Replies
      Latest reply on Dec 1, 2019 11:34 PM by roee84
      roee84 Level 1 Level 1 (0 points)

        For my VPN app for macOS, implemented with Packet Tunnel Provider, I'm using BSD sockets, over UDP, and they are non-blocking.
        If I'm trying to send large files (~1GB), I'm getting the error ENOBUFS (No buffer space available).
        I've tried setting SO_SNDBUF, but it didn't help.

        In addition, I saw this very old discussion about this problem at macOS - https://lists.freebsd.org/pipermail/freebsd-hackers/2004-January/005369.html


        Is there anything I can do to solve it? At the moment I can't send big files via my app.

        • Re: PacketTunnelProvider - ENOBUFS
          meaton Apple Staff Apple Staff (20 points)

          This is a difficult one because SO_SNDBUF will only have an impact on a single write with UDP as opposed to all data written to a buffer like in TCP.  There are a few options here; first, I am not sure how realistic this is in your application, but I would take a look at using TCP for file transfer instead of UDP.  TCP will provide you with the buffer and packet book keeping required for large sequential transmissions often needed in file transfers.  Second, I would look into using a modern API such as NWConnection in Network Framework to create such file transfer connections.  Network Framework will also get you away from having to use sockets and manually managing a lot of the code needed to maintain and transfer data.