Problems with DNS package in TCLLIB and the TCLUDP package 
Author Message
 Problems with DNS package in TCLLIB and the TCLUDP package

Hi,

I've verified this happens on both the Linux and Windows platforms.
After installing the TCLUDP extension I try to perform DNS queries.
I've been able to determine that UDP packets are being sent and received
almost instantly but the data isn't being read in into memory (by TCL
that is) until a dns query is performed using tcp.  For example, below
is what I'm seeing from tcl shell (the latest UDPTCL extension is loaded
too, TCLUDP 1.0.7):

% package require dns
1.2.1
% set u_tok [dns::resolve ietf.org]
::dns::1
% dns::status $u_tok
connect
% dns::name $u_tok
can't read "state(reply)": no such element in array
% set t_tok [dns::resolve ieee.org -protocol tcp]
::dns::2
% dns::status $u_tok
ok
% dns::name $u_tok
ietf.org
% dns::status $t_tok
ok
% dns::name $t_tok
ieee.org

As I've mentioned above, I've been able to verify that the requests are
being sent and received using UDP but for some reason the event handler
being setup in the dns.tcl script isn't being called until I do a query
in TCP.  Does anyone have any ideas?  I've been crawling around in the
guts of the dns.tcl script for a few hours now and haven't been able to
determine much.  Some interesting things would be I noticed that by
default the UDP socket is placed in a blocking state but the TCP socket
is non-blocking.  The manual page for fileevent says that this is
usually a bad idea for writing event driven stuff like this.  I modified
the dns.tcl script to place the UDP socket in a non-blocking mode but I
still get the same result.  So, does anyone have any ideas as to what's
causing this?

Also note that although not shown above I'm NOT using localhost as my
namesever.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled.  I do not wish my account at HP to
become a spam haven.



Sun, 17 Feb 2008 22:34:50 GMT  
 Problems with DNS package in TCLLIB and the TCLUDP package
It's rather weird to respond to one's own message before anyone else has
but I wanted to add a curiosity I've uncovered while debugging this issue.

I noticed in the source code for the tcludp package that when the
upd_open command is called it actually opens the socket with the
following code:
statePtr->channel = Tcl_CreateChannel(&Udp_ChannelType, channelName,
                                      (ClientData) statePtr,
                                      (TCL_READABLE | TCL_WRITABLE |
TCL_MODE_NONBLOCKING));

As you can see, the guts of this procedure by default open in
non-blocking.  However, I found that calling fconfigure on the socket
opened by this call shows that its in a blocking state unless fconfigure
is called to place it otherwise.

Any help would be appreciated.  Thanks.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled.  I do not wish my account at HP to
become a spam haven.



Mon, 18 Feb 2008 06:21:15 GMT  
 Problems with DNS package in TCLLIB and the TCLUDP package

Quote:

>Hi,

>I've verified this happens on both the Linux and Windows
>platforms. After installing the TCLUDP extension I try to perform DNS
>queries. I've been able to determine that UDP packets are being sent
>and received almost instantly but the data isn't being read in into
>memory (by TCL that is) until a dns query is performed using tcp.  For
>example, below is what I'm seeing from tcl shell (the latest UDPTCL
>extension is loaded too, TCLUDP 1.0.7):

>% package require dns
>1.2.1
>% set u_tok [dns::resolve ietf.org]
>::dns::1
>% dns::status $u_tok
>connect
>% dns::name $u_tok
>can't read "state(reply)": no such element in array
>% set t_tok [dns::resolve ieee.org -protocol tcp]
>::dns::2
>% dns::status $u_tok
>ok
>% dns::name $u_tok
>ietf.org
>% dns::status $t_tok
>ok
>% dns::name $t_tok
>ieee.org

>As I've mentioned above, I've been able to verify that the requests
>are being sent and received using UDP but for some reason the event
>handler being setup in the dns.tcl script isn't being called until I

Try running an event loop - add
 after 2000 {set forever 1} ; vwait forever
if this is a tclsh script.
--
Pat Thoyts                            http://www.patthoyts.tk/
To reply, rot13 the return address or read the X-Address header.
PGP fingerprint 2C 6E 98 07 2C 59 C8 97  10 CE 11 E6 04 E0 B9 DD


Mon, 18 Feb 2008 23:24:48 GMT  
 Problems with DNS package in TCLLIB and the TCLUDP package

Quote:


>>Hi,

>>I've verified this happens on both the Linux and Windows
>>platforms. After installing the TCLUDP extension I try to perform DNS
>>queries. I've been able to determine that UDP packets are being sent
>>and received almost instantly but the data isn't being read in into
>>memory (by TCL that is) until a dns query is performed using tcp.  For
>>example, below is what I'm seeing from tcl shell (the latest UDPTCL
>>extension is loaded too, TCLUDP 1.0.7):

>>% package require dns
>>1.2.1
>>% set u_tok [dns::resolve ietf.org]
>>::dns::1
>>% dns::status $u_tok
>>connect
>>% dns::name $u_tok
>>can't read "state(reply)": no such element in array
>>% set t_tok [dns::resolve ieee.org -protocol tcp]
>>::dns::2
>>% dns::status $u_tok
>>ok
>>% dns::name $u_tok
>>ietf.org
>>% dns::status $t_tok
>>ok
>>% dns::name $t_tok
>>ieee.org

>>As I've mentioned above, I've been able to verify that the requests
>>are being sent and received using UDP but for some reason the event
>>handler being setup in the dns.tcl script isn't being called until I

> Try running an event loop - add
>  after 2000 {set forever 1} ; vwait forever
> if this is a tclsh script.

Sorry for the ignorance, but where exactly in the script would I put this?

--

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled.  I do not wish my account at HP to
become a spam haven.



Tue, 19 Feb 2008 21:38:30 GMT  
 Problems with DNS package in TCLLIB and the TCLUDP package

Quote:

> Try running an event loop - add
>  after 2000 {set forever 1} ; vwait forever
> if this is a tclsh script.

Essentially, this was the fix.  With the help of some fellow engineers
at work, we isolated it to being that (most likely) the event handler,
the fileevent stuff, was being registered after the response had been
received and placed on the socket by the kernel.  I was getting my data
(from the udp transaction) when doing a dns query using tcp because of
the overhead involved with tcp transactions.  My fix looks something
like this:

# start script and source libs, load packages tcllib and tcludp

set u_tok [dns::resolve hp.com]

vwait $u_tok

Thanks.

---------------------------------------------
Andrew R. Falanga (a non-HP employee)
Hewlett-Packard Company
11311 Chinden Blvd.
Boise, Idaho
---------------------------------------------
Please note: The e-mail address is purposely
mangled.  I do not wish my account at HP to
become a spam haven.



Tue, 26 Feb 2008 02:56:23 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. The dns package in tcllib question

2. Problems with ntp (time package at tcllib)

3. problems with tcllib's pop3 package

4. HELP! Envy Packaging Problem: Packaging Proxies

5. DNSBL query using dns package

6. htmlparse package in tcllib

7. abort transfers in tcllib's ftp package?

8. SMTP package in tcllib.kit?

9. Finding Tcllib Module Package dependeciy tree

10. ftp Library Package (tcllib 1.4) SSL?

11. tcllib mime package: reading from stdin

12. Some downloadable examples/applications based on comm tcllib package

 

 
Powered by phpBB® Forum Software