Google Groups Home
Help | Sign in
problem getting gawk inet working with udp, tcp okay - solved: 3.1.6 okay
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Grant  
View profile
 More options Jul 26, 9:08 pm
Newsgroups: comp.lang.awk
From: Grant <g_r_a_n...@dodo.com.au>
Date: Sun, 27 Jul 2008 11:08:38 +1000
Local: Sat, Jul 26 2008 9:08 pm
Subject: problem getting gawk inet working with udp, tcp okay - solved: 3.1.6 okay
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/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google