<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/3043" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2002-11-19T05:07:10-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/3043</id>

		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-11-19T05:07:10-04:00</updated>

		<published>2002-11-19T05:07:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13357#p13357</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13357#p13357"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13357#p13357"><![CDATA[
This line is the cause<div class="codebox"><p>Code: </p><pre><code>set updatedatadata [split [::http::data $token] \n]</code></pre></div>It should read<br><div class="codebox"><p>Code: </p><pre><code>set updatedata [split [::http::data $token] \n]</code></pre></div>No, it doesn't store it to the HD. It works by reading it into memory, then every 10 mins, it will replace this stored information with a fresh set of data.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Nov 19, 2002 5:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Taiyaki]]></name></author>
		<updated>2002-11-18T21:36:40-04:00</updated>

		<published>2002-11-18T21:36:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13345#p13345</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13345#p13345"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13345#p13345"><![CDATA[
hmm...i'm trying with that code but it doesn't seem to work...<br><br>i edited a little bit of it<br><div class="codebox"><p>Code: </p><pre><code>package require http #set url of the update fileset url "http://www3.telus.net/dekan/newrlsd.txt"#set current dateset cdate [clock format [clock seconds] -format "%m/%d/%y"]set cmd "!updates" bind pub -|- $cmd updates set updatedata {} proc updates {nick handle host chan text } { global updatedata url cdate putquick "NOTICE $nick :Updates for the day of $cdate" foreach data $updatedata { puthelp "NOTICE $nick :$data" } } bind time - "*0 *" update:timer proc update:timer {args} { global updatedata url cdateset token [::http::geturl $url -command [list mycallback]] } update:timer proc mycallback {token} { global updatedata url cdate set updatedatadata [split [::http::data $token] \n] ::http::cleanup $token }</code></pre></div>hmmm, can anyone help?  actually i don't really understand what is going on =/  this is my first script...it's prolly too much for me aha  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2212">Taiyaki</a> — Mon Nov 18, 2002 9:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Taiyaki]]></name></author>
		<updated>2002-11-18T21:02:42-04:00</updated>

		<published>2002-11-18T21:02:42-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13344#p13344</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13344#p13344"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13344#p13344"><![CDATA[
thanks for the fast reply  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"> <br><br>and so the *.txt file will be copied to my HD every 10 mins and the output will be read from that file right?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2212">Taiyaki</a> — Mon Nov 18, 2002 9:02 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-11-18T20:52:38-04:00</updated>

		<published>2002-11-18T20:52:38-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13343#p13343</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13343#p13343"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13343#p13343"><![CDATA[
There are several method of doing this, including using the system you currently use.<br><br>Yes, the sample file is small, and would only reflect sample out, and not the bandwidth and size issues.<br><br>Adapt you current code to somthing like the following.<br><div class="codebox"><p>Code: </p><pre><code>package require httpset cmd "!updates"bind pub -|- $cmd updatesset updatedata {}proc updates {nick handle host chan text } {  global updatedata  set cdate [clock format [clock seconds] -format "%m/%d/%y"]  putquick "NOTICE $nick :Updates for the day of $cdate"  foreach data $updatedata {    puthelp "NOTICE $nick :$data"  }}bind time - "*0 *" update:timerproc update:timer {args} {  set token [::http::geturl "http://www3.telus.net/dekan/newrlsd.txt" -command [list mycallback "$mydata"]]} update:timerproc mycallback {token} {     global updatedata    set updatedatadata [split [::http::data $token] \n]    ::http::cleanup $token} </code></pre></div>The above, will output data, with it's contents being no more than ten mins old.<br><br>A bind is setup, to call a script every 10 mins. At this time, it will download a copy of the data, using the non-blobking system you have setup.<br><br>Everytime a client requests data, it will reply with the cached information, rather than a freshly downloaded copy.<br><br>This will stop DOS attacks to a certain extent, as it saves making a download for every request.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Nov 18, 2002 8:52 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Taiyaki]]></name></author>
		<updated>2002-11-18T20:16:26-04:00</updated>

		<published>2002-11-18T20:16:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13341#p13341</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13341#p13341"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13341#p13341"><![CDATA[
hmm...well if this method i'm using is going to be ineffective (since the text file being shown in the script is only a sample...the actual file is pretty big) is there another way i can achieve this effect?<br><br>like how can i grab info from a remote website (doesn't have to be a txt file cuz i can parse the output) and display it in a NOTICE efficiently?<br>is this even possible with eggdrop/TCL?  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_cry.gif" width="15" height="15" alt=":cry:" title="Crying or Very sad"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2212">Taiyaki</a> — Mon Nov 18, 2002 8:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2002-11-18T15:34:39-04:00</updated>

		<published>2002-11-18T15:34:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13330#p13330</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13330#p13330"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13330#p13330"><![CDATA[
Taiyaki, the reason it is probably slow is that you are using "asynchronous" transfer. Asynchronous transfer is when Tcl only transfers information in the background when it is available. Using synchronous transfer,your script will stick at that one line until it is totally complete. So asynchronous is very good, because it prevents your bot from freezing.<br><br>However, since Eggdrop also uses asynchronous transfer, there is a problem when using Tcl to do the same thing. Namely, Tcl will only check if there is information ready about once every second. Normally, it will check almost continuously, so it's very fast.<br><br>What this could mean is it's only downloading a few lines of the webpage per second, which makes it very slow.<br><br>Unfortunately there isn't much you can do about it. One solution is to execute a program like wget in the background, which will run separate from eggdrop, and thus be able to download at full speed.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Mon Nov 18, 2002 3:34 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-11-18T15:14:52-04:00</updated>

		<published>2002-11-18T15:14:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13325#p13325</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13325#p13325"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13325#p13325"><![CDATA[
The fastest sugestion, and least network hungry, is to do periodic updates.<br><br>Either using a timer, or the time bind, you would store downloaded data, into a variable whioch is made global.<br><br>On the request of information, your bot can then output the information.<br><br>You may also want to issue a ::http::cleanup. Failure to do so, will incur a nice memory overhead, each and every time the above script is loaded. This will happen until all memory is used up, or the system refuses to issue any more.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Nov 18, 2002 3:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Taiyaki]]></name></author>
		<updated>2002-11-18T14:36:23-04:00</updated>

		<published>2002-11-18T14:36:23-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13322#p13322</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13322#p13322"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13322#p13322"><![CDATA[
hmm actually there isn't much under &lt;snip&gt;, lol.  this is like my first TCL script  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_lol.gif" width="15" height="15" alt=":lol:" title="Laughing"> <br><br>let's see here, this is the whole thing<br><div class="codebox"><p>Code: </p><pre><code>package require httpset cmd "!updates"bind pub -|- $cmd updatesproc updates {nick handle host chan text } {set cdate [clock format [clock seconds] -format "%m/%d/%y"] putquick "NOTICE $nick :Updates for the day of $cdate" set mydata "$nick" set token [::http::geturl "http://www3.telus.net/dekan/newrlsd.txt" -command [list mycallback "$mydata"]] }proc mycallback {mydata token} {     set data [::http::data $token]     foreach z [split $data \n] {         putquick "NOTICE $mydata :$z"     } }</code></pre></div><br>i don't really understand all the possible causes that you have listed out, but can you please look at my code and see maybe why there is a lag?   or maybe suggest a new method to read the text file (<a href="http://www3.telus.net/dekan/newrlsd.txt" class="postlink">http://www3.telus.net/dekan/newrlsd.txt</a>) faster?  thanks in advance  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2212">Taiyaki</a> — Mon Nov 18, 2002 2:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-11-18T08:54:25-04:00</updated>

		<published>2002-11-18T08:54:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13301#p13301</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13301#p13301"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13301#p13301"><![CDATA[
The single word "YUK!" comes to mind.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Nov 18, 2002 8:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2002-11-18T07:35:31-04:00</updated>

		<published>2002-11-18T07:35:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13296#p13296</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13296#p13296"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13296#p13296"><![CDATA[
We should make a version of http.tcl that works with eggdrop's builtin network code.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Mon Nov 18, 2002 7:35 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-11-18T06:08:39-04:00</updated>

		<published>2002-11-18T06:08:39-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13291#p13291</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13291#p13291"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13291#p13291"><![CDATA[
In reality, we need to see what is under snip, to make better judgment.<br><br>There are many factores that can affect the length of time ti takes to display the output.<br><br>File size: If the file you are downloading is large, then you have to wait until the machine can download the whole file. Seeing as you output line for line, then this may not be the case, but is valid never the less.<br><br>DNS servers: While downloads may be fast, the NS lookup that has too occur before connecting may take a long time.<br><br>Blocking: Most likely cause<br><br>You codes uses a method, to prevent blocking by the download operation.<br><br>Whilst preventing blocking is the best way, regardless of file size (though only using small files may benefit more from blocking operations), it will cause more overhead, both in CPU time and in code processed.<br><br>To use non-blocking mode, there has to be a mechanism in place, to download and store data, between the actual call to download, and the output.<br><br>The HTTP package provides these functions for you, however, they are not transparent. They do require a certain bit of background processing to work. This done using the Tcl event loop.<br><br>In Tcl, this can be entered using a few commands, vwait and update, it can also be done in C.<br><br>These functions will process incoming and outgoing buffered data, that have been declared to do so, using the fileevent functions, and any other bacvkground process like after.<br><br>In eggdrop main loop, the Tcl_DoOneEvent function is called, so that these events can be processed.<br><br>From what I remember, eggdrop only issues this command once per second, which results in a partial block. IE, a socket buffer will fill, Tcl_DoOneEvent will process the buffer, and the socket will have to wait until the next time Tcl_DoOneEvent is called.<br><br>Thus, a blocking HTTP get, will process the whole file in one go, while sacrifising IRC connectivity due to the block. Non-blocking will be slowly processed in eggdrop, due to the way Tcl_DoOneEvent is called.<br><br><em class="text-italics">Even more long winded still</em><br><br>There are method to get around this in eggdrop. 1: Decrease the time in the event loop (This has been sugested before on this forum, though the outcome may be unpredictable), 2: Process background tasks yourself more often.<br><br>The HTTP package provide the -blocksize option, which allows you to set the amount of blocks being read in each chunk. This defaults to 8192. This should be more than adiquate, though you can change this.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Mon Nov 18, 2002 6:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Taiyaki]]></name></author>
		<updated>2002-11-18T04:46:06-04:00</updated>

		<published>2002-11-18T04:46:06-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=13290#p13290</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=13290#p13290"/>
		<title type="html"><![CDATA[Why is it slow when i use HTTP::geturl ?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=13290#p13290"><![CDATA[
i think i'd better explain my problem  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"> <br><br>i use the HTTP::geturl to grab lines from a remote text file, and then display it in a NOTICE<br><div class="codebox"><p>Code: </p><pre><code>set mydata "$nick" set token [::http::geturl "http://www3.telus.net/dekan/newrlsd.txt" -command [list mycallback "$mydata"]] &lt;snip&gt;proc mycallback {mydata token} {     set data [::http::data $token]     foreach z [split $data \n] {          putquick "NOTICE $mydata :$z"   } }</code></pre></div>this method works, but i'm just wondering why there is such a delay (like a 10-20second delay) from when I type the trigger to when the NOTICE arrives.  And how do I get rid of this lag?  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_confused.gif" width="15" height="15" alt=":-?" title="Confused"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2212">Taiyaki</a> — Mon Nov 18, 2002 4:46 am</p><hr />
]]></content>
	</entry>
	</feed>
