Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Tk Realtime data aquisition

by jaschwartz (Novice)
on May 05, 2009 at 21:05 UTC ( [id://762074]=note: print w/replies, xml ) Need Help??


in reply to Tk Realtime data aquisition

I am having some difficulty using your two scripts: If I start your sender script first I get an unspecified connect error "Could not connect: Unknown error at ....". If I start the monitor script first the sender script scrolls through some numbers, but nothing shows in the monitor graph as it also shows it not connected. Please help as I think I can greatly apply this script, but can't seem to get past these script/socket issues. Thanks :)

Replies are listed 'Best First'.
Re^2: Tk Realtime data aquisition
by zentara (Archbishop) on May 06, 2009 at 18:47 UTC
    You start the big Tk script first, and it will just sit there waiting for a connection. Start the smaller sender script second, and it should connect automatically.....works here I just tried it.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
      I started the big Tk script first, the monitor, and then started the smaller, the sender. The command line window I started it from shows incrementing numbers and its sent random number. But, nothing shows up in the monitor graph. I think some of the issue is that the monitor always shows "Not connected." I am not sure how to force it to connect? I am using a windows xp win32, is this the same as what you are using? After using a netstat -a, I see both the Listening on 7070 and the the established, but yet nothing shows up in the graph, I suspect this may be an issue in the the handle_connection subrutine. I uncommented your "print message line." But, nothing is printed. I suspect that handle_connection is not getting far enough to execute handle_connection. Your thoughts or advice?
        I am using a windows xp win32, is this the same as what you are using?

        Eh, sorry no. I use linux, it works. In all likelihood your problem is that, the Tk::fileevent (which monitors and reads the socket), is unreliable on Windows. I'm not going thru the code right now, but that is a very common problem on win32. The quick fix for you, is to remove the fileevent and use a timer ( every 10 or 20 ms ) to read the socket.

        Thats just an educated guess, and it should work. The fileevent problem was supposedly only on win32 pipes, not sockets. So I'm perplexed, you might post another node and ask win32 users if it works for them. You may have other issues I'm unaware of, like your firewall not allowing the connection, or other localhost issues. Possibly its a blocking problem, does it suddenly spurt out alot of data if you let it run for a few minutes? There are problems with getting non-blocking reads on win32 pipes...but this is a socket?

        Another way around it, is to switch to Gtk2.....you can use the same idea to write to a Gnome2::Canvas or Goo::Canvas. Gtk2 has a fix for the win32 fileevent problem, with it's comparable Glib::IO::Watch widget.

        Its all just a guess on my part, I avoid win32. What you should do, is find some Tk code, that works with sockets on win32, and test to see what the code differences are. Maybe you just need a /r/n for newlines, in the sender script, to tell it to flush, but Perl should handle that automagically on your platform.

        print $sock "$send \r\n ";

        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://762074]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-03-28 19:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found