eminence / udt-rs

UDT bindings for Rust
BSD 2-Clause "Simplified" License
32 stars 12 forks source link

UDT buffer error on OS X possibly due to oversized UDP receive buffer #2

Open mcginty opened 8 years ago

mcginty commented 8 years ago

I'm getting an error when calling socket.listen() on OS X:

UdtError {
  err_code: 1003,
  err_msg: "Connection setup failure: unable to create/configure UDP socket: No buffer space available."
}

UNLESS I specify

sock.setsockopt(UdtOpts::UDP_RCVBUF, 5590000i32);

then everything works like magic.

eminence commented 8 years ago

Yeah, this matches what I've seen myself. For example: https://github.com/eminence/udt-rs/blob/master/tests/test.rs#L11-L15

I admit I don't know why this is necessary

eminence commented 8 years ago

I found this post on the UDT mailing list that talks about this issue:

Yes, this is a known issue too (I should have add a known issue list...)

The reason is that UDT tries to allocate a rather large socket buffer 
(setsockopt) that OS X does not support. On Linux or Windows, they will 
set the socket buffer to the maximum system value; however, OS X will 
return error.

So the solution is, you can either change your system parameter to allow 
larger socket buffer size (at least 20MB), or set UDT option (UDT_SNDBUF 
and UDT_RCVBUF) to smaller values (e.g., 64KB). See the commented 
setsockopt lines in appserver and appclient for examples.

Since this is a known UDT issue, I'm going to find a way to document this and then close this issue.
(As you seem to be the only user of udt-rs at the moment, I'm happy to take suggestions regarding the best/most visible way to document this :smile: )

mcginty commented 8 years ago

I wonder if this is something that udt-rs can do by default using some platform-specific code when built for OS X?

winkmichael commented 5 years ago

Anyone work out a fix or work around for this?

mcginty commented 5 years ago

@winkmichael iirc, the workaround was to set the sockopt as mentioned in that first issue description.