Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In Linux I have no problem dumping tons of data into a domain socket, but the same code on OS X 10.6.2 blows up after about 65 records. The socket reader code looks like

#!/usr/bin/perl

use strict;
use warnings;

use IO::Socket;

unlink "foo";
my $sock = IO::Socket::UNIX->new (
        Local    => 'foo',
        Type     => SOCK_DGRAM,
        Timeout  => 600,
) or die "Could not create socket: $!\n";

while (<$sock>) {
        chomp;
        print "[$_]\n";
}

And the client code looks like

#!/usr/bin/perl

use strict;
use warnings;

use IO::Socket;

my $sock = IO::Socket::UNIX->new (
    Peer     => 'foo',
    Type     => SOCK_DGRAM,
    Timeout  => 600,
) or die "Could not create socket: $!\n";

for my $i (1 .. 1_000_000) {
    print $sock "$i\n" or die $!;
}

close $sock;

The error message I get is No buffer space available at write.pl line 15.. It seems fairly obvious that there is a difference in the buffer size between Linux and OS X, but I don't know how to set it OS X (or what the possible negative side effects might be).

share|improve this question

2 Answers 2

This code is really not good code. It sends packets as fast as it can, and it will run out of buffer space. I don't know why linux doesn't, but that's an oddity, not something to rely on.

Increasing buffer space won't help, it will just hide the bad code.

share|improve this answer
    
Without knowing what the buffer size is, how can I know when to back off? If I use INET sockets it works just fine in OS X. –  Chas. Owens Jan 15 '10 at 2:22

You can try

sysctl -w kern.ipc.maxsockbuf=8000000
sysctl -w net.inet.tcp.sendspace=4000000
sysctl -w net.inet.tcp.recvspace=4000000

but I would heed the suggestion from Michael Graff that you should include some backoff and retry logic in your application code

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.