Very Strange while udp socket polling.

Vadim Melihow slon@satgate.net
Tue Oct 10 17:48:00 GMT 2006


Hello,

Just very simple program
and very strange behaviour....

int main()
{
	int fd;
	struct pollfd pds[2];
	struct sockaddr_in sai;

	fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	sai.sin_family      = AF_INET;
	sai.sin_port        = htons(6666);
	sai.sin_addr.s_addr = INADDR_ANY;
	bind(fd, (struct sockaddr *)&sai,sizeof(sai));
	printf("Before poll. Sleep 10 sec.\n");
	sleep(10);
	pds[0].fd     = fd;
	pds[0].events = POLLIN|POLLERR;
	pds[0].revents = 0;
	poll(pds, 1, (int)(5000));
	printf("After poll\n");
	sleep(1000);
}

So, before "poll(pds, 1, (int)(5000));"

netstat -a -n shows
Slon@HOBOT ~/
$ netstat -a -n -o |grep 2860
  UDP    0.0.0.0:6666           *:*                                    2860


And after poll
Slon@HOBOT ~/
$ netstat -a -n -o |grep 2860
  UDP    0.0.0.0:6666           *:*                                    2860
  UDP    127.0.0.1:3074         *:*                                    2860


why 'poll' create and bind new socket??
Is this a bug??

tested on
cygwin1.dll v.1.5.21 a some older....

Vadim G Melihow


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



More information about the Cygwin mailing list