[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] /inet/tcp receive TCP packet bug
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] /inet/tcp receive TCP packet bug |
Date: |
Tue, 29 Dec 2015 12:54:23 -0500 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi,
On Tue, Dec 29, 2015 at 04:56:07PM +0300, Владимир Губарев wrote:
> Excuse me for previous poor request.
> I wanted to tell the following thigs:
> I wish to implement WebSocket protocol in GAWK. Everything was ok: i could
> setup connections(because it is HTTP headers with RS="\r\n") and send
> dataframed(bytes) from gawk to client's browser. But i'm absolutely cannot
> receive dataframes (XOR`ed bytes and some header) from client. When you want
> to read from /inet/tcp, u're using "|& getline" construction, but what if
> where are sequence of bytes without record separator? When gawk will read
> dataframe and will wait until EOF or something else(io.c->get_a_record) from
> read. Then only one way to interrupt excess read it is use
> PROCINFO["READ_TIMEOUT"]. But by this method you cannot get your previous
> read buffer. So you cannot read sequence of bytes by GAWK from /inet/tcp/.
> Did i explain well my problem?
>
I think I understand a bit better now. My sense is that you have two problems:
1. you want to do non-blocking I/O on the socket; and 2. you want to read
binary data from the socket, instead of the textual record-oriented data
that getline handles. Is that correct?
1. The gawk master branch has some new features that enable
non-blocking I/O to work properly. You can download this version of gawk here:
git clone git://git.savannah.gnu.org/gawk.git
Please read the docs regarding the new PROCINFO[input-file, "RETRY"] feature.
You will also need to install the gawkextlib select extension from here:
http://sourceforge.net/projects/gawkextlib/files/
You may not need the full power of select multiplexing, but you will at least
need to use the bundled set_non_blocking function.
2. I don't think there's currently any way to read binary data that isn't
terminated with a record separator. However, I think it should be pretty easy
to create library extension functions that provide access to the read and write
system calls. You might even be able to persuade me to add this to the
gawkextlib select extension. But I don't know if this will solve all of your
problems. I must confess that gawk doesn't seem to me like a great choice for
processing XDR-encoded data. How will you decode the XDR data? That would
seem to require a gawk extension library to interface to the XDR library.
Regards,
Andy