| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Hi there, I'm trying to use the gawk 3.1.5 socket communications, tcp protocol works as expected, but udp crashes at the server side. Using Linux. #!/usr/bin/gawk -f # server BEGIN { service = "/inet/tcp/8888/0/0" for (; {printf "%s", strftime("%F.%T") service |& getline close(service, "from") printf " %-15s ", $0 if ($1 == "shutdown") { print "shutdown" |& service print ""; exit } n = split($0, a, "") reply = "" for (i = n; i > 0; i--) reply = reply a[i] print reply |& service close(service, "to") print reply } } #!/usr/bin/gawk -f # client BEGIN { service = "/inet/tcp/0/localhost/8888" } { print $0 |& service close(service, "to") printf "wait for reply: " service |& getline reply close(service, "from") print reply } Successful run with tcp client-server opertion: Server-side: $ ./server 2008-07-27.10:46:32 this is a test tset a si siht 2008-07-27.10:46:35 shutdown Client side: $ echo "this is a test" | client wait for reply: tset a si siht $ echo shutdown | client wait for reply: shutdown Now, if I change the "/inet/tcp..." to "/inet/udp..." in the 'service' var on both client and server, I get: Server-side: $ ./server 2008-07-27.10:47:08gawk: ./server:8: fatal: can't open two way socket `/inet/udp/8888/0/0' for input/output (No such file or directory) Client side: $ echo "this is a test" | client wait for reply: ^C $ Client required Ctrl-C to exit. The server crashed when I hit Enter at the client screen, so it seemed to be properly blocking on read from the port. Server line 8 is 'service |& getline'. Just before sending this post I installed gawk-3.1.6, udp works! Me happy, I send this anyway to get the problem plus fix into google. Grant. -- http://bugsplatter.mine.nu/ |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.