[PD] Different socket implementation in Windows and Linux

David Jonsson (II) David at interactiveinstitute.se
Tue Mar 5 11:27:52 CET 2002


Hi Miller

In fact I had the same problem even when I ran both server and client on 
the same Windows98 machine.

I have looked a bit deeper into this now and found solutions.

I think the solution would be to set the TCP_NODELAY to 1 and to set 
SO_RCVBUF and SO_SNDBUF  to 0.

In x_net.c something has to be added around this code segment.

#ifdef IRIX
        /* this seems to work only in IRIX but is unnecessary in
    Linux.  Not sure what NT needs in place of this. */
    if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, 0, 0) < 0)
        post("setsockopt failed\n");
#endif

Set
int i=0;
int one=1;
setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &i, sizeof(i));
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));

As far as I can see you should use these settings on all platforms.
You should probably also set
setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &i, sizeof(i));
on the sending socket (but it should have the same effect as 
TCP_NODELAY. However if there is another application except PD at the 
receiver then this setting would have an effect.)

The SO_SNDBUF and SO_RCVBUF sets the kernel buffer to 0 which means all 
data gets immediately sent to network or fed into the application. This 
should also fix any delay on a UDP socket.

David

Miller Puckette wrote:

>hi David,
>
>I've noticed that Windows seems only to deliver TCP packets around
>5 times per second (between machines; not on a single machine which
>runs with lower latency.)  I've never known what to do about this...
>Where do I feed teh TCP_NOWAIT flag?
>
>cheers
>Miller
>O
>On Mon, Mar 04, 2002 at 04:43:20PM +0100, David Jonsson (II) wrote:
>
>>I run PD 0.43-4
>>
>>The TCP server socket implementation in Windows PD should have the 
>>option TCP_NOWAIT so that data gets sent immediately when it arrives in 
>>the buffer.
>>
>>This is the case in the Linux version.
>>
>>Today I write like 15 times per second to the net and the Linux version 
>>receives this fast but the Windows version only produces a output 
>>approximately 5 times per second.
>>
>>I'm not an expert on sockets but I suppose this is what differs?  Maybe 
>>I should add that I run Windows 98 on the client.
>>
-- 
David Jonsson

Interactive Institute AB
phone +46-703-000 370  or  +46-8-783 24 49   Timezone GMT+1
org no 556557-3077       http://www.interactiveinstitute.se/









More information about the Pd-list mailing list