X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com Subject: sending an empty UDP packet. MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII From: Tanaka Akira Date: Fri, 30 Jun 2006 19:18:05 +0900 Message-ID: <87irmjeykr.fsf@m17n.org> Lines: 79 User-Agent: T-gnus/6.15.7 (based on Oort Gnus v0.08) SEMI/1.14.6 (Maruoka) FLIM/1.14.6 (Marutamachi) APEL/10.6 Emacs/21.4 (i386-pc-linux-gnu) MULE/5.0 (SAKAKI) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 #include #include #include 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/