Hi. I have a trouble to send an empty UDP packet. $ uname -a CYGWIN_NT-5.1 D2RP7F1X 1.5.19(0.150/4/2) 2006-01-20 13:28 i686 Cygwin
I run a UDP server (written in Ruby) on port 8888 as follows on a terminal: $ ~/ruby/bin/ruby -rsocket -ve 's = UDPSocket.new; s.bind("0.0.0.0", 8888); loop { p s.recv(100) }' ruby 1.9.0 (2006-06-08) [i386-cygwin] I compiled following UDP client on another terminal. $ cat send.c #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> int main(int argc, char **argv) { int s; int ret; char *buf; struct sockaddr_in addr; if (argc != 4) { puts("usage: send ipaddr port data"); exit(1); } addr.sin_family = AF_INET; ret = inet_aton(argv[1], &addr.sin_addr); if (ret == 0) { perror("inet_aton"); exit(1); } addr.sin_port = htons(atoi(argv[2])); buf = argv[3]; s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) { perror("socket"); exit(1); } ret = sendto(s, buf, strlen(buf), 0, (struct sockaddr *)&addr, sizeof(addr)); if (ret == -1) { perror("sendto"); exit(1); } return 0; } $ gcc -o send.exe send.c I expect send.exe can send an empty packet as follows. But the server receive no data. The server prints nothing. $ ./send.exe 127.0.0.1 8888 '' $ ./send.exe 127.0.0.1 8888 '' $ ./send.exe 127.0.0.1 8888 '' $ ./send.exe 127.0.0.1 8888 '' When I use send.exe to send 1, 2 and 3-bytes data, it works fine. The server prints "a", "ab", "abc". $ ./send.exe 127.0.0.1 8888 a $ ./send.exe 127.0.0.1 8888 ab $ ./send.exe 127.0.0.1 8888 abc I can send an empty UDP packet using a mswin32 (non-cygwin) ruby as follows. The server prints "". (The server still runs by cygwin ruby. cygwin ruby can receive empty UDP packet.) $ ~/19/bin/ruby -rsocket -ve 'UDPSocket.new.send("", 0, "127.0.0.1", 8888)' ruby 1.9.0 (2005-07-22) [i386-mswin32] But I cannot send an empty UDP packet. $ ~/ruby/bin/ruby -rsocket -ve 'UDPSocket.new.send("", 0, "127.0.0.1", 8888)' ruby 1.9.0 (2006-06-08) [i386-cygwin] Is there a way to send an empty UDP packet from cygwin? -- Tanaka Akira -- 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/