<?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/15727" />

	<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>2008-05-14T09:55:32-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-14T09:55:32-04:00</updated>

		<published>2008-05-14T09:55:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82914#p82914</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82914#p82914"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82914#p82914"><![CDATA[
Hmm... never had that issue with nonblocking channels and "<strong class="text-strong">readable</strong>" fileevents. Can't tell 'bout "writable", as I hardly ever use 'em...<br><br>Properly configured, the readable-event would only be dispatched once for each tcp-packet recieved until a whole line can be recieved. Also, the way eggdrop invokes Tcl_DoOneEvent() should make it very hard to steal 100% cpu unless you use some loop within your event-handler.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed May 14, 2008 9:55 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2008-05-14T06:41:58-04:00</updated>

		<published>2008-05-14T06:41:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82913#p82913</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82913#p82913"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82913#p82913"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>if {[info exists _forever_]} else {unset _forever_}if {[catch {socket localhost 25} sock]} {  puts "Error couldn't connect"  set _forever_ {}} else {  fileevent $sock writable [list socket_async_callback $sock] }proc socket_async_callback {sock} {  global _forever_  if {[string equal {} [fconfigure $sock -error]]} {    while {![eof $sock]} {      puts $sock "blah blah"      flush $sock      gets $sock buf      puts "$buf"    }  } else {    puts [fconfigure $sock -error]  }  close $sock  set _forever_ {}}vwait _forever_</code></pre></div>This should work in a shell script, i do not agree with fconfigure because it will drive the cpu crazy, i used to do it as well and a socket script ended up using 100% cpu, that's why i use/prefer flush instead, ..<br><br>You should ignore/comment the lines with _forever_ once you use this in an eggdrop  script.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Wed May 14, 2008 6:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[honeybee]]></name></author>
		<updated>2008-05-10T11:47:40-04:00</updated>

		<published>2008-05-10T11:47:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82871#p82871</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82871#p82871"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82871#p82871"><![CDATA[
<blockquote class="uncited"><div>I would still recommend using the http-package, as it pretty much does the same - unless you wish to practice using tcl-events.</div></blockquote>well i guess http would be the better choice but I sitll want to try tcl-event its logical and clearing many things.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7174">honeybee</a> — Sat May 10, 2008 11:47 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-10T11:29:25-04:00</updated>

		<published>2008-05-10T11:29:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82870#p82870</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82870#p82870"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82870#p82870"><![CDATA[
Yup. Except bgerror is expected to have one parameter (message);<div class="codebox"><p>Code: </p><pre><code>proc bgerror {msg} { putlog "bgerror: $msg" putlog "  ($::errorCode) $::errorInfo"}</code></pre></div>I would still recommend using the http-package, as it pretty much does the same - unless you wish to practice using tcl-events.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat May 10, 2008 11:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[honeybee]]></name></author>
		<updated>2008-05-10T09:41:45-04:00</updated>

		<published>2008-05-10T09:41:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82868#p82868</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82868#p82868"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82868#p82868"><![CDATA[
<blockquote class="uncited"><div>Try searching the forum for threads related to "fileevent", as this is the mechanism you'll end up using for events.<br><br>A very rough example however:<div class="codebox"><p>Code: </p><pre><code>proc isReadable {socket} { if {[gets $socket line] &lt; 0} {  if {[eof $socket]} {   close $socket   #Cleanup code: Connection closed by remote host   isFinal $socket   return  } } else {  lappend ::readBuffer($socket) $line }}proc isFinal {socket} { #do something intelligent with the data we received, and then cleanup... foreach line $::readBuffer($socket) {  putlog "$line" } unset ::readBuffer}...set fId [socket $hostIP $hostPort]fconfigure $fId -blocking 0set ::readBuffer($fId) [list]fileevent $fId readable [list isReadable $fId]</code></pre></div>This will open a connection to $hostIp:$hostPort, and read all data one line at a time, appending them to the global list readBuffer, until the remote end closes the connection. Then isFinal will be called to do something creative with the received data.</div></blockquote>thanks, I'm tryin to redo it with your suggestion. <br>But for event based code I need to have bgerror to catch the exact errors right?<br>proc bgerror {} {<br> putlog "bgerror: errorInfo: $::errorInfo"<br> putlog "bgerror: errorCode: $::errorCode"<br>}<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7174">honeybee</a> — Sat May 10, 2008 9:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2008-05-09T18:22:47-04:00</updated>

		<published>2008-05-09T18:22:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82854#p82854</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82854#p82854"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82854#p82854"><![CDATA[
It would most definitley be easier for you (given the original code you posted) to simply use the http package (with the -command switch) or the egghttp.tcl script.  There is an egghttp.tcl example at <a href="http://www.tclscript.com/egghttp_tut.shtml" class="postlink">http://www.tclscript.com/egghttp_tut.shtml</a> which wouldn't be hard to apply to the http package as well.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Fri May 09, 2008 6:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-09T15:16:43-04:00</updated>

		<published>2008-05-09T15:16:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82849#p82849</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82849#p82849"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82849#p82849"><![CDATA[
Try searching the forum for threads related to "fileevent", as this is the mechanism you'll end up using for events.<br><br>A very rough example however:<div class="codebox"><p>Code: </p><pre><code>proc isReadable {socket} { if {[gets $socket line] &lt; 0} {  if {[eof $socket]} {   close $socket   #Cleanup code: Connection closed by remote host   isFinal $socket   return  } } else {  lappend ::readBuffer($socket) $line }}proc isFinal {socket} { #do something intelligent with the data we received, and then cleanup... foreach line $::readBuffer($socket) {  putlog "$line" } unset ::readBuffer}...set fId [socket $hostIP $hostPort]fconfigure $fId -blocking 0set ::readBuffer($fId) [list]fileevent $fId readable [list isReadable $fId]</code></pre></div>This will open a connection to $hostIp:$hostPort, and read all data one line at a time, appending them to the global list readBuffer, until the remote end closes the connection. Then isFinal will be called to do something creative with the received data.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri May 09, 2008 3:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[honeybee]]></name></author>
		<updated>2008-05-09T14:59:19-04:00</updated>

		<published>2008-05-09T14:59:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82848#p82848</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82848#p82848"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82848#p82848"><![CDATA[
thanks for your prompt reply can you please show me an example?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7174">honeybee</a> — Fri May 09, 2008 2:59 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-09T14:56:59-04:00</updated>

		<published>2008-05-09T14:56:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82847#p82847</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82847#p82847"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82847#p82847"><![CDATA[
Nothing that would'nt cause the same amount of rewriting..<br><br>Basically, what you need, is to remove all socket communications out of that proc, and use tcl's event-engine to make your request and read the result. As long as your proc keeps running, it will prevent your eggdrop from doing anything else, possibly causing it to timeout and disconnect.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri May 09, 2008 2:56 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[honeybee]]></name></author>
		<updated>2008-05-09T14:43:15-04:00</updated>

		<published>2008-05-09T14:43:15-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82846#p82846</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82846#p82846"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82846#p82846"><![CDATA[
yes but I will have to re-do whole script again which is kinda too much at the moment. I will surely look into it when have time.<br>do you have suggestion to fix this issue temp<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7174">honeybee</a> — Fri May 09, 2008 2:43 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-05-09T11:30:35-04:00</updated>

		<published>2008-05-09T11:30:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82837#p82837</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82837#p82837"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82837#p82837"><![CDATA[
The cause for the lag is this part:<div class="codebox"><p>Code: </p><pre><code>  while {[eof $sock] != 1} {# do this...  }</code></pre></div>This will prevent your eggdrop from performing any further actions until the whole webpage has been recieved, or connection has been dropped. Changing to async connections will not make much difference.<br><br>I would recommend that you have a look at the http-package instead, as this package supports callback functions.<br><br>Sockets opened with "socket" has no way of interacting with your tcl parser or eggdrop environment, other than the means you provide using gets, puts, read, etc. Unless you actually read the received text using puts or read, it'll just sit in an input buffer until the socket is closed.<br>Also, knowing the url &amp; port of the remote site has no impact on the security of your eggdrop - just as it won't on your web-browser...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri May 09, 2008 11:30 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[honeybee]]></name></author>
		<updated>2008-05-09T10:48:34-04:00</updated>

		<published>2008-05-09T10:48:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=82835#p82835</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=82835#p82835"/>
		<title type="html"><![CDATA[socket issues.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=82835#p82835"><![CDATA[
I'm trying to access my website with<div class="codebox"><p>Code: </p><pre><code>if {[catch {set sock [socket $myurl $myport] } err]} {    putlog "error: $err"  return 0} else {  puts $sock "GET /administrator.cgi?pass=$adminpass&amp;mode=viewxml HTTP/1.0"  puts $sock "User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9)"  puts $sock "Host: $myurl"  puts $sock "Connection: close"  puts $sock ""  flush $sock  while {[eof $sock] != 1} {# do this...  }}  </code></pre></div>this works fine but issue is by eggdrop lags alot.<br>should i change it to.<div class="codebox"><p>Code: </p><pre><code>if {[catch {set sock [socket -async $myurl $myport] } err]} {</code></pre></div>just a thought.<br>I also thought of changing <div class="codebox"><p>Code: </p><pre><code>  puts $sock ""  flush $sockto:if [info exists sock] {close $sock}</code></pre></div>Another question is is it safe to use sock because i read some where in users post sock connetion can be used to access your bot and shell if someone know the url &amp; port.<br><br>Thank you.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7174">honeybee</a> — Fri May 09, 2008 10:48 am</p><hr />
]]></content>
	</entry>
	</feed>
