public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Weird behavior with writes to a unix socket pair
@ 2019-09-26 14:55 Petr Skočík
  0 siblings, 0 replies; only message in thread
From: Petr Skočík @ 2019-09-26 14:55 UTC (permalink / raw)
  To: cygwin

Hi,

I've been testing the effects of the SO_RCVBUF/SO_SNDBUF socket options
on unix sockets on various platforms, and I've run into some curious
unix socket behavior on Cygwin (independent of the SO_RCVBUF/SO_SNDBUF
options).


This piece of code should get blocked in one of the writes (and it does
so for regular pipes):


#include <sys/socket.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
	int p[2];
	socketpair(AF_LOCAL, SOCK_STREAM, 0,p);
	/*pipe(p);*/
	/*setsockopt(p[0], SOL_SOCKET, SO_RCVBUF, &(int){1},sizeof(int));*/
	/*setsockopt(p[0], SOL_SOCKET, SO_SNDBUF, &(int){1},sizeof(int));*/
	/*setsockopt(p[1], SOL_SOCKET, SO_RCVBUF, &(int){1},sizeof(int));*/
	/*setsockopt(p[1], SOL_SOCKET, SO_SNDBUF, &(int){1},sizeof(int));*/
	ssize_t n;
	for(unsigned j=0;j<10000;j++)
		for(unsigned char i=1; i!=0; i++){
			printf("%u\n", j*256+i);
			if(0>(n=write(p[1],&i,1))) perror("write");
		}


}

but with a unix socket socket pair a first couple of writes proceed
quickly and then the writes continue to proceed with ever-increasing
intervals between them.

I don't see why it should behave like this and I think you guys might
want to look into why it does.

Best regards,
Petr Skocik




--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-09-26 14:38 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-26 14:55 Weird behavior with writes to a unix socket pair Petr Skočík

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).