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

	<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>2009-03-25T03:08:44-04:00</updated>

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

		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-25T03:08:44-04:00</updated>

		<published>2009-03-25T03:08:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88083#p88083</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88083#p88083"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88083#p88083"><![CDATA[
<blockquote class="uncited"><div>Keep in mind, it was not tcl that did not pass your "no connect/connect/no connect" test, but rather your tcl-coding.</div></blockquote>yes, I spoke out of exciitement<br><br>I shall rephrase...<br><br><em class="text-italics">This code passed the "no connect/connect/no connect" test in which I was unable to get TCL to do properly on its own.</em><br><br>I didn't mean to imply that TCL was at fault.. its true that my coding skills in TCL aren't that advanced  (though, I gotta admit, I think I did pretty darn good for what I have to work with).<br><br>I also mis-stated about "fetch" being included with FreeBSD..  to state properly:  <em class="text-italics">*I* found that, after installing a bare-bones version of FreeBSD 6x and then installing SOME "ports" and then uninstalling them, I note that, the command "fetch" was available; "wget", however, is not available. I did not install knowingly, any ports exclusive to fetch.. (and I needed fetch initially to retrieve the ports) I believe the command "fetch" is included in the basic install (bare-bones) of FreeBSD 6x.</em><br><br>the code above is a <em class="text-italics">working</em> example of how to use "fetch" as an external "connection manager" for TCL.. which, in my opinion, I found to be simpler to set up, and more reliable and less-intrusive in the current application in which I have used TCL coding to achieve.<br><br>there <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":-)" title="Smile"><br><br>Now, what does my eggdrop <strong class="text-strong">DO</strong> with all of this?? my egggy does the following:<br><br>1.. grabs chat stats and generates them- posts them to my website** <br>2.. monitors the current state of the cast server- checks which input mount is active and passes this data to the output compiler.<br>3.. Takes said output and generates the appropiate webpages<br>4.. updates channel topic and displays song/stream/dj info to the chatroom.<br>5.. RECORDS the stream and then makes it available for immediate download; 'instant podcast'. (admin controlled)<br>6.. monitors and CONTROLS the local playout (RAC) system- and with active feedback- does NOT "hammer" the RAC or server with blind commands)<br>7.. "auto play" feature will start/stop the RAC remotely- when a guest DJ logs in (no countdowns and admin kick-start commands nessessary!)<br>8.. allows preveliged DJ/caster access and AUTOMATICALLY switches them onto the broadcast chain upon login into the server- again, no countdowns or admin-kick commands nessessary.<br>9.. "master control" input and local studio stream-detect<br>10.. SMART implementation of active direct-control commands to the RAC by admins and super admins (exclusively)system can detect if the playout is available,  which mode is set and if the RAC is available/online and sends messages of the current state to the admin who requested them.<br>11.. instant update of song/title/DJ info via chatroom commands as well as change-detect and topic/channel stream/title requests.<br>12.. manages a "bug" in icecast where listener counts are not properly-transferred to the current mount currently online; bug is corrected and the counts are accurately-displayed. (called the "hop detector")<br><br>new features in development:<br>auto-detect and  implemation of guest DJs  local playout system.. and them to display that in place via RAC channel and not SC channel<br><br>auto-timed podcast creation and RSS updating via simple chatroom commands<br><br>playlist search and pick  lets listeners search out a tune  then  auto-cue it into the current playing list for airplay.<br><br>and many more as I think of them hehehe<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br><br><br>**feature currently disabled while I'm in debugging mode<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Wed Mar 25, 2009 3:08 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-24T14:21:46-04:00</updated>

		<published>2009-03-24T14:21:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88071#p88071</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88071#p88071"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88071#p88071"><![CDATA[
Glad you got it working.<br>Keep in mind, it was not tcl that did not pass your "no connect/connect/no connect" test, but rather your tcl-coding.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Mar 24, 2009 2:21 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-24T01:48:26-04:00</updated>

		<published>2009-03-24T01:48:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88050#p88050</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88050#p88050"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88050#p88050"><![CDATA[
UPDATE!<br><div class="codebox"><p>Code: </p><pre><code>proc  RacSkt {} {        global RacIP RacPort RacInfo        if {([catch {set RacInfo [exec fetch -q -A -m -T 1 -o - http://$RacIP:$RacPort/x/playing.cgi];};])} {                putlog {Connection NOT present};                return 0;        } else {                putlog {Connection present!};                return 0;        };}</code></pre></div><br>WORKS LIKE A CHARM!<br><br>and its <em class="text-italics">simple</em>, it doesn't hang the bot, doesn't flood the stack with dead sockets, reads the states and data <em class="text-italics">reliably</em> and, most-importantly, its <strong class="text-strong">FASSSSST</strong>!<br><br>timeout is 1 sec.. PLENTY of time to read and close  <em class="text-italics">and it reads/closes everytime!  no more dead sockets or fin_wait_2s!</em><br><br>admittingly, I'm still testing.. but I am quite excited at the results so far...<br><br>it PASSED the "no connect/connect/no connect" test- something TCL on its own was completely UNABLE to do...<br><br>fetch is a basic internal command to FreeBSD so its included as a "freebie" and I'm really impressed- I donno why I didn't think of this before! (okay, actually, I did.. but I couldn't get it working...)<br><br>I have more testing to do.. but this is looking REALLY GOOD so far!<br><br>MORE UPDATES:<br><br>more tests were done 100% SUCCESS!<br>it CAN read ICECAST <em class="text-italics">PERFECTLY</em>!<br>it will even AUTH in properly as well; <strong class="text-strong">NIIIIIICE!!!</strong><br><br>oh this changes EVERYTHING... <br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Tue Mar 24, 2009 1:48 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-23T18:45:18-04:00</updated>

		<published>2009-03-23T18:45:18-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88046#p88046</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88046#p88046"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88046#p88046"><![CDATA[
Proper code...<br><blockquote class="uncited"><div>fileevent readable NEVER works and fileevent writable ALWAYS works- even if the conneection isn't!</div></blockquote>Work as in triggering?<br><br>This requires an understanding of when a channel is considered readable or writable. To quote the fileevent manpage:<br><blockquote class="uncited"><div>A channel is considered to be readable if there is unread data available on the underlying device. A channel is also considered to be readable if there is unread data in an input buffer, except in the special case where the most recent attempt to read from the channel was a gets call that could not find a complete line in the input buffer. This feature allows a file to be read a line at a time in nonblocking mode using events. A channel is also considered to be readable if an end of file or error condition is present on the underlying file or device. It is important for script to  check for these conditions and handle them appropriately; for example, if there is no special check for end of file, an infinite loop may occur where script reads no data, returns, and is immediately invoked again.<br><br>A channel is considered to be writable if at least one byte of data can be written to the underlying file or device without blocking, or if an error condition is present on the underlying file or device.</div></blockquote>As I stated in my previous post, you leave the writable event going, which means it'll trigger over and over and ... I thought I mentioned that writable also includes error conditions, but I guess I missed it. Nevertheless my code handles it.<br>As you fail to close the socket, should any error condition arise, the socket will remain writable. Since your proc never raises an error condition, fileevent will never drop the event handler by it's own either. Hence you get an infinite loop. But that, I already mentioned in my previous post...<br><br><br>Oh, and if I was not clear enough, the reason for your 5min freeze in that other post.. this is the very line that causes it:<div class="codebox"><p>Code: </p><pre><code>while {(![eof $PlaySock])} {set PlayInfo [gets $PlaySock];}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Mar 23, 2009 6:45 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-23T14:10:34-04:00</updated>

		<published>2009-03-23T14:10:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88042#p88042</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88042#p88042"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88042#p88042"><![CDATA[
yes!<br>I have to nest the whole thing otherwise it FLOODS the  shell with pipe errors and returns to prompt almost immediately!<br><br>fileevents don't work correctly either..<br><br>fileevent readable NEVER works and  fileevent writable ALWAYS works- even if the conneection isn't!<br><br>this makes it UNRELIABLE and causes errors and crashes the damn thing!<br><br>sorry for the "hard to read"  word-wrap and I'm mostly blind- so I have to  use long tabs to SEE the  lines..  but it doesn't paste well in the wiindow...<br><br>so, what the <strong class="text-strong">BEEEEEP</strong> am I missing here?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Mon Mar 23, 2009 2:10 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-23T13:06:58-04:00</updated>

		<published>2009-03-23T13:06:58-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88041#p88041</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88041#p88041"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88041#p88041"><![CDATA[
Uff.. not to be rude, but that code is hard to read.<br><br>Your code, will indeed hang your eggdrop in certain conditions. This is the result of a combination of several issues in your code.<br><br>I took the liberty of re-indenting your code, and pasting one of the procs here:<div class="codebox"><p>Code: </p><pre><code>proc    RacNfo {RacSock CA} {  global RacIP RacPort RacInfo  putlog {Rac Test}  if {    ([catch {      after cancel $CA      flush $RacSock      puts $RacSock "GET /x/playing.cgi HTTP/1.0\r\nUser-Agent: Mozilla\r\nHOST $RacIP:$RacPort\r\n\r\n\r\n\r\n"      flush $RacSock      while {(![eof $RacSock])} {        set RacInfo [gets $RacSock]      }      catch {flush $RacSock}      catch {close $RacSock}    }])  } {    set RacInfo ""    return 0  }}</code></pre></div>First, don't nest 20 commands into one catch!<br>This is bound to blow up in your face. Especially if you include vital clean up code in the very same catch.<br><br>If there is any error within that first catch, you'll never reach the line where you close the socket. Hence the socket will remain active. Since you catch everything in that proc, it will never throw an error, and the fileevent will remain valid.<br><br>Second, you never disable the fileevent. This means your RacNfo proc will be called over and over and over for as long as the socket remains writeable.<br><br>Third, you use the gets/read function in a proc that's triggered on writable, not readable. Hence you have no ideas whatsoever if there is anything there to read. This can mess with the <strong class="text-strong">fblocked</strong> and <strong class="text-strong">eof</strong> status commands.<br>Also remember, that on sockets, there will not be an eof condition until the remote end closes the connection.<br><br>All in all, whenever an async connection fails, <strong class="text-strong">flush</strong> will return an error condition. As the close-commands are in the same catch-script, and the whole script is terminated, the socket remains open, and the fileevent active. This, in its turn, keeps triggering the writable event:<blockquote class="uncited"><div>A channel is considered to be writable if at least one byte of data can be written to the underlying file or device without blocking, or  if  an  error condition is present on the underlying file or device.</div></blockquote>A cleanup of your code, which should work (although I did not test it) follows... You'll end up with response headers aswell in RacInfo, so I guess you'll like to do some cleanup once the request is completed...<div class="codebox"><p>Code: </p><pre><code>proc RacNfo {socket after} { set ::RacInfo "" after cancel $after puts $socket "GET /x/playing.cgi HTTP/1.0\r\nUser-Agent: Mozilla\r\nHost: $::RacIP: $::RacPort\r\n\r\n" if {[catch {flush $socket} status} {  putlog "Error in $socket: $status"  close $socket  return } fileevent $socket writable "" fileevent $socket readable [list RacReadNfo $socket]}proc RacReadNfo {socket} { if {[eof $socket]} {  putlog "Socket $socket is eof, closing..."  close $socket  return } append ::RacInfo [read $socket]}</code></pre></div>Ohh, one more thing. That code of yours could be considered "hammering", as it will make a new connection each 10 seconds, regardless of the status of the previous one. Since your cleanup-code is flawed, in some cases you may very well end up with numerous "pending" connection, filling up the address translation table in your NAT-router (which, btw, is the only reasonable way I could see one system downing a complete subnet these days).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Mar 23, 2009 1:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-23T12:04:45-04:00</updated>

		<published>2009-03-23T12:04:45-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=88038#p88038</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=88038#p88038"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=88038#p88038"><![CDATA[
okay, I spent another night  screwing around with things..<br><br>first the CODE (totally rewritten/derived from NML-375's examples):<br><div class="codebox"><p>Code: </p><pre><code>proc RunLoop1 {} {RacSkt; utimer 10 [list RunLoop1]; return 1;};proc RunLoop2 {} {HeartBeat; utimer 10 [list RunLoop2]; return 1;};proc    RacSkt {} {        global RacIP RacPort        if {([catch {set RacSock [socket -async $RacIP $RacPort]; fconfigure $RacSock -blocking 0 -buffersize 10;}])||([catch {set PlaySock [socket -async $RacIP $RacPort]; fconfigure $PlaySock -blocking 0 -buffersize 10;}])} {                catch {close $RacSock};                catch {close $PlaySock};                return 0;        } else {                set CA [after 1800 [list close $RacSock];];                set CB [after 1800 [list close $PlaySock];];                fileevent $RacSock writable [list RacNfo $RacSock $CA];                fileevent $PlaySock writable [list PlayNfo $PlaySock $CB];        };}proc    RacNfo {RacSock CA} {        global RacIP RacPort RacInfo        putlog {Rac Test}        if {([catch {after cancel $CA; flush $RacSock; puts $RacSock "GET /x/playing.cgi HTTP/1.0\r\nUser-Agent: Mozilla\r\nHOST $RacIP:$RacPort\r\n\r\n\r\n\r\n"; flush $RacSock; while {(![eof $RacSock])} {set RacInfo [gets $RacSock];}; catch {flush $RacSock}; catch {close $RacSock};}])} {        set RacInfo "";        return 0;        };}proc    PlayNfo {PlaySock CB} {        global RacIP RacPort PlayInfo        putlog {Play Test}        if {([catch {after cancel $CB; flush $PlaySock; puts $PlaySock "GET /x/playlist.cgi HTTP/1.0\r\nUser-Agent: Mozilla\r\nHOST $RacIP:$RacPort\r\n\r\n\r\n\r\n"; flush $PlaySock; while {(![eof $PlaySock])} {set PlayInfo [gets $PlaySock];}; catch {flush $PlaySock}; catch {close $PlaySock};}])} {        set PlayInfo "";        return 0;        };}proc    HeartBeat {} {          putlog {Still alive...};}</code></pre></div>now the test conditions:<br>Eggdrop started with the RAC <em class="text-italics">NOT</em> connected: (Radio <strong class="text-strong">off</strong>)<ul><li>[10:37] Still alive...<br>[10:37] Still alive...<br>[10:37] Still alive...<br>[10:37] Still alive...<br>[10:37] Still alive...<br>[10:37] Still alive...<br>[10:37] Still alive...</li></ul>..then the RAC is connected (radio <strong class="text-strong">on</strong>)<ul><li>[10:37] Still alive...<br>[10:38] Still alive...<br>[10:38] Still alive...<br>[10:38] Still alive...<br>[10:38] Rac Test   <em class="text-italics">&lt;-- connection detected</em><br>[10:38] Play Test<br>[10:38] Rac Test<br>[10:38] Still alive...<br>[10:38] Play Test<br>[10:38] Still alive...<br>[10:38] Rac Test<br>[10:38] Play Test<br>[10:38] Still alive...</li></ul>..and now the RAC is disconnected once more.. (Radio <strong class="text-strong">off</strong>)<ul><li>[10:38] Rac Test    <em class="text-italics">&lt;-notice the script is still detecting a DEAD connection!</em><br>[10:38] Play Test<br>[10:39] Still alive...<br>[10:39] Rac Test<br><em class="text-italics">Heres where the Eggdrop  freezes... completely non-responsive!</em><br>[10:45] timer: drift (lastmin=40, now=45)<br>[10:45] timer: drift (lastmin=41, now=45)<br>[10:45] timer: drift (lastmin=42, now=45)<br>[10:45] timer: drift (lastmin=43, now=45)<br>[10:45] timer: drift (lastmin=44, now=45)<br>[10:45] (!) timer drift -- spun 5 minutes   <em class="text-italics">&lt;- you asked where the 5 mins comes from? its <strong class="text-strong">RIGHT THERE!</strong></em><br>[10:45] net: eof!(write) socket 4 (Broken pipe,32)<br>[10:45] Writing user file...<br>[10:45] * EXIT<br>&gt;     <em class="text-italics">&lt;- Eggdrop exits and drops to prompt</em></li></ul>This is [one of] the error condition I've been trying to convey to you.. (NML-375)<br><br>conclusion: <strong class="text-strong">FAIL!</strong><br><br>DjZ<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Mon Mar 23, 2009 12:04 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-19T02:59:48-04:00</updated>

		<published>2009-03-19T02:59:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87947#p87947</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87947#p87947"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87947#p87947"><![CDATA[
I agree!<br><br>it seems that I have a <em class="text-italics">kernel</em> issue, if nothing else.. <br><br>I will tell you that <em class="text-italics">fileevent</em> didn't work- even the fileevents in YOUR code examples..<br><br>fileevent $Sock readable [?proc? $Sock]<br><br>never triggers except <em class="text-italics">maybe</em> once every 500 'hits' or so..<br><br>fileevent $Sock writable [?proc? $Sock]<br><br><em class="text-italics">always</em> fired- even if the connecion was never completed!<br><br>(of course, then comes the "broken pipe" error followed with an immediate drop to prompt)<br><br>but I guess that doesn't count- if I stupid enough to call a connection a socket- even if it was merely done for clearity...<br><br>no matter- I seemed to have knocked the subnet off line (again) with all of this..  The ISP sent me an email stating they are capping me to 5 G's now... <em class="text-italics">yes I somehow took them down for over 12 hours?? don't ask HOW...  I don't have a clue!</em><br><br>now, back to the main thread...<br><br>The guy testing Python said "it worked as expected and  the RAC didn't go mental" meaning he didn't see anything wrong with the reading of the RAC except  clusters of "no route to host" etc... (hes running Linux of some flavor)<br><br>yes, I have already began to think its a NIC or kernel issue... perhaps BSD 6x isn't the thing to use... who knows.<br><br>a 5G/month cap isn't good for anything streaming-related- (unless maybe I stream in dial-up speeds..) well.. I'll  pull my CoLo and be DONE with all of it...<br><br>yeah, I know-  quite a defeatist attitide.. but thats how I <em class="text-italics">feel</em> about all of this at the moment!<br><br>-DjZ-<br>:/:/<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Thu Mar 19, 2009 2:59 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-17T11:29:05-04:00</updated>

		<published>2009-03-17T11:29:05-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87911#p87911</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87911#p87911"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87911#p87911"><![CDATA[
I'm using a mobile unit at the moment, so I'll be brief..<br><br>Python and tcl use the vey same calls to the system kernel in order to establish the connection. Neither tcl nor eggdrop are having isues negotiating the connection. It's your kernel that's having the issues..<br>The only big difference between using a separate python process and tcl-script within eggdrop's process, is which proces gets blocked.<br><br>The messages 'No Route to Host', 'Remote Host unreachable', etc originates from the IP-stack within the kernel, they're not generated by php, tcl, python, etc...<br><br>The whole point of these coding-exercises have been to avoid blocking-mode in eggdrop, noting else.<br><br>Yes, your ISP has some akward packet filtering - even so, simply dropping SYN packets is nothing new, and properly written software have been able to cope with that for a long time. In most cases by using proper non-blocking/asynchronous code and proper timeouts, along with either polling or some kind of event dispatcher.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Mar 17, 2009 11:29 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-17T10:16:48-04:00</updated>

		<published>2009-03-17T10:16:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87908#p87908</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87908#p87908"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87908#p87908"><![CDATA[
I have to admit...<br><br>I have been lacking sleep lately.. <br><br>and I have mis-represented the  problems I have been experiencing...<br><br>so, let me try once again to explain whats been happening..<br><br>first off, that guy trying to use Python <em class="text-italics">DID</em> get it to work.. he said its working "as expected" and I can see him hitting the RAC...  he says hes seeing a lot of "no route to host" errors and lots of timeouts...  but python is simply <em class="text-italics">timing out</em> or reporting "no route to host".<br><br>what I'm seeing, is TCL having trouble negotiating the <em class="text-italics">handshake</em> of the RAC connection..  and this is before the connection establishes and starts any of our fconfigures or, otherwise, ANY other config/behaviors.  python sees this too- but merely <em class="text-italics">ignores</em> it I'm assuming.. (or treating it as a "no route to host") in either case,  its this point, that where TCL seems to be having issues.. <em class="text-italics">My ISP has admitted to me that they do "tamper" with the connection protocols to hamper/prevent bit-torrent and other peer-2-peer file-sharing, however they won't disclose to me exactly what they are doing to the protocols.</em> To me, it appears they "proxy" the incoming connections and then "redistribute" them simular to what a NAT does..  y(ou gotta understand, this ISP is GOOFY- the entire TOWN I'm in IS on the LAN and IPs are assigned on a per pay/per machine basis; but besides that, its a strange situation nevertheless- and since they are the ONLY ISP I have access to, I have to deal with it. <br><br>To sum it up "Rural college town ISP" <em class="text-italics">need I say more??</em><br><br>(God, I sure DO miss Chicago sometimes!)<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Tue Mar 17, 2009 10:16 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-16T14:36:12-04:00</updated>

		<published>2009-03-16T14:36:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87887#p87887</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87887#p87887"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87887#p87887"><![CDATA[
<blockquote class="uncited"><div>hi again...<br><br>a couple things to update ya...<br><br>first.. couldn't I just use:<br><div class="codebox"><p>Code: </p><pre><code>after 30000 [catch {close $socket}]</code></pre></div>??</div></blockquote>Problem here is that you'd execute the catch {close $socket} command instantly, rather than delaying it 30 seconds.<br><blockquote class="uncited"><div>of course I can't!  because the connection has to be made <em class="text-italics">beforehand</em> and thats were its getting locked up!</div></blockquote>Please re-read my previous post, and it'll tell you exactly where to insert the correct code.. That is, _after_ you've initiated the (async) connection...<br><blockquote class="uncited"><div>fileevents aren't quite working either..  although "writable" reports ALL the time, "readable" doesn't report AT ALL! (or its intermittant at best).</div></blockquote>Could you post a showcase of this, including the code you were using?<br><blockquote class="uncited"><div>and even in async mode.. its <em class="text-italics">STILL</em> hanging on the initial connection...</div></blockquote>Then you are doing something wrong, async by nature will return instantly, regardless of the state of the socket (or connection).<br><blockquote class="uncited"><div>Also,<br><br>Someone wanted to try accessing the RAC connection for S&amp;Gs, using python.. and he's having the same problems..  either no connection then connection to nowhere and/or connection but no data and a complete lockup/stall/crash of the script.. even in python, connection error-control is <em class="text-italics">totally worthless</em>!</div></blockquote>I'm no expert in python, but as far as I can guess, python uses the very same underlying networking layer..<br><blockquote class="uncited"><div>I've been wondering, myself if, in fact, its the <em class="text-italics">onboard NIC</em> on the server's motherboard thats causing the issues.. (the server that the eggie is residing) The RAC is on a windows box on the end of a WiMax (wireless) connection.. the NIC on the server is an Intel PRO/1000 MT DA (onboard) maaybe someone  else out there might know of any issues with using this NIC with an eggie/TCL? tests to localhost all work properly and </div></blockquote>Eggdrop doesn't ever see your NIC...<br>It only sees the C-API provided from stdlibC, which in it's turn interacts with the system kernel. No userspace program, generally, should be able to access the underlying hardware. The only possible exception would be advanced debug/troubleshooting/firmware update-software, which then would require root permissions.<br>In essence, anything that would work with php should work with eggdrop. Just remember that eggdrop is a single-threaded application, and blocking operations will prevent it from handle other events until the block ends.<br><blockquote class="uncited"><div>I have NO PROBLEMS with error-control or connection timeout/stalling issues with the icecast server running on the same box though there are issues if I try to run with "gets" instead of "read" which "gets" will render nothing.. I believe this is caused by icecast sending XSL output (and likely omitting any \r\n's) Which reminds me.. <em class="text-italics">anyone out there know how I can set up a  basic http auth to icecast?? I have tried NML's suggestion but that isn't accepting it.. icecast wants  login:<a href="mailto:password@admin.server.com">password@admin.server.com</a> for login.. and TCL thinks theres a "sintax error"</em></div></blockquote>"gets" returning noting: correct. Solution here is to use gets while retrieving the headers, and then switching over to read.<br>"syntax error": tcl knows nothing about http protocol, hence it'll say nothing regarding syntax error. Http servers (such as icecast) do know http, and will issue such messages if you do not follow protocol.<br>Regarding http://user:pass@host:port/path/file URI's, with http they suggest the "Basic" authentication scheme, where user and passwords are sent as request headers, and not included in the URI when sending the request.<br><blockquote class="uncited"><div>NML:<br>How would you like the opportunity to plug your code (your code, your way) into the RAC connection and  try to reach the RAC?  perhaps you'll better understand the problem(s) once you experience them yourself.. thing is, I'll need to know when you're doing it so I can "connect and disconnect" when the tests require it...<br><br>just let me know..<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>Actually, your network issues are rather easily replicated with a WinXP system with firewall enabled. Just try to connect to an unused port, and the connection is silently dropped rather than refused. What I find very strange, is how you manage to freeze your application for several minutes. My 2.6 kernel will drop the connection attempt within 30 seconds without any kind of custom timeout code.<br><br>I am working on a simplified rewrite of the http-package to remove the nasty blocking behaviour during connection, although progress is slow due to other interests and projects.<br>I'll post when I get some further work done...<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Mar 16, 2009 2:36 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-16T04:24:43-04:00</updated>

		<published>2009-03-16T04:24:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87882#p87882</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87882#p87882"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87882#p87882"><![CDATA[
hi again...<br><br>a couple things to update ya...<br><br>first.. couldn't I just use:<br><div class="codebox"><p>Code: </p><pre><code>after 30000 [catch {close $socket}]</code></pre></div>??<br><br>of course I can't!  because the connection has to be made <em class="text-italics">beforehand</em> and thats were its getting locked up!<br><br>fileevents aren't quite working either..  although "writable" reports ALL the time, "readable" doesn't report AT ALL! (or its intermittant at best).<br><br>and even in async mode.. its <em class="text-italics">STILL</em> hanging on the initial connection...<br><br>Also,<br><br>Someone wanted to try accessing the RAC connection for S&amp;Gs, using python.. and he's having the same problems..  either no connection then connection to nowhere and/or connection but no data and a complete lockup/stall/crash of the script.. even in python, connection error-control is <em class="text-italics">totally worthless</em>!<br><br>I've been wondering, myself if, in fact, its the <em class="text-italics">onboard NIC</em> on the server's motherboard thats causing the issues.. (the server that the eggie is residing) The RAC is on a windows box on the end of a WiMax (wireless) connection.. the NIC on the server is an Intel PRO/1000 MT DA (onboard) maaybe someone  else out there might know of any issues with using this NIC with an eggie/TCL? tests to localhost all work properly and <br><br>I have NO PROBLEMS with error-control or connection timeout/stalling issues with the icecast server running on the same box though there are issues if I try to run with "gets" instead of "read" which "gets" will render nothing.. I believe this is caused by icecast sending XSL output (and likely omitting any \r\n's) Which reminds me.. <em class="text-italics">anyone out there know how I can set up a  basic http auth to icecast?? I have tried NML's suggestion but that isn't accepting it.. icecast wants  login:<a href="mailto:password@admin.server.com">password@admin.server.com</a> for login.. and TCL thinks theres a "sintax error"</em><br><br>NML:<br>How would you like the opportunity to plug your code (your code, your way) into the RAC connection and  try to reach the RAC?  perhaps you'll better understand the problem(s) once you experience them yourself.. thing is, I'll need to know when you're doing it so I can "connect and disconnect" when the tests require it...<br><br>just let me know..<br><br>-DjZ-<br><img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Mon Mar 16, 2009 4:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-12T11:54:46-04:00</updated>

		<published>2009-03-12T11:54:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87806#p87806</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87806#p87806"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87806#p87806"><![CDATA[
You know, in the very same paragraph I pointed out the reason we're currently stuck at that (and also hints on how to bypass it). Namely, I didn't add a timeout function, which I believe I mentioned earlier aswell...<br><br>In any case, it would be something as trivial as adding something like this in the appropriate place:<div class="codebox"><p>Code: </p><pre><code>#Straight after we've initated the connect and setup the first fileevent, add this:after 30000 [list safeClose $socket]...#Also make sure our safeClose proc existsproc safeClose {token} { catch {close $token}}</code></pre></div>This should add nicely to my posted code back on page 2. It uses a hard timeout of 30 seconds, where it will terminate the connection regardless of it's current state. If you intend to make request more frequent than that, I'd suggest you cut down on the timeout.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Thu Mar 12, 2009 11:54 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[dj-zath]]></name></author>
		<updated>2009-03-12T05:24:40-04:00</updated>

		<published>2009-03-12T05:24:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87802#p87802</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87802#p87802"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87802#p87802"><![CDATA[
<blockquote class="uncited"><div>As such, we are currently relying on the underlying network layer to change the state of the channel to something like connection failed (and thus triggering tcl to close the channel identifier)</div></blockquote>yes.. THATS the problem!<br><br>the underlying network layer is 1.. reporting connections to machines that aren't there.. and 2.. reporting them <em class="text-italics">intermittantly</em><br><br>I gather from all this that what I [need] to do here is <em class="text-italics">NOT</em> going to be that simple or straight-foreward.. using the http package or not...  I have even currently implemented your examples in the best-possable means that I can..  it still "hoses" the eggie (and now it seems the whole <em class="text-italics">SERVER</em>- with icecast and the ircd is also being effected by it as well... since you said.. <em class="text-italics">its running out of resources...</em><br><br>I may have to consider running <strong class="text-strong"><em class="text-italics">PHP</em></strong> for this instead of TCL.. call me an idiot...  (though you probably have reached <em class="text-italics">that</em> conclusion allready!)<br><br>thanks for the help in any case.<br><br><em class="text-italics">I'll now reload my AOL disc to reload the net! </em> &lt;smirk&gt;<br><br>-DjZ-<br> :/:/<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10318">dj-zath</a> — Thu Mar 12, 2009 5:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2009-03-06T15:35:03-04:00</updated>

		<published>2009-03-06T15:35:03-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=87729#p87729</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=87729#p87729"/>
		<title type="html"><![CDATA[[SOLVED] Back for More - Socket timeout help needed]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=87729#p87729"><![CDATA[
Once again, when using asynchronous connections, a socket is created regardless whether the connection failed, succeeded, or is yet pending. The only time it will not create a socket, is if the <strong class="text-strong">socket</strong> command is unable to make sense of the address/port, or the underlying network layer is completely unavailable.<br><br>In this case, good/bad socket says absolutely nothing whether we can reach the server or not. It just tells us whether the socket could be created or not (not if the connection could be established).<br><br>As for your tests... Use the full feature of catch, as illustrated in my examples.<blockquote class="uncited"><div>...<br>       If  the varName argument is given, then the variable it names is set to the result of the script evaluation.  When the return code from the script is 1<br>       (TCL_ERROR), the value stored in varName is an error message.  When the return code from the script is 0 (TCL_OK), the value stored in resultVarName is<br>       the value returned from script.<br>...</div></blockquote>That is, use this instead when creating your socket:<div class="codebox"><p>Code: </p><pre><code>...if {[catch {socket -async $CastIP $CastPort} CastSock]} { putlog "Cast Socket not created: $CastSock" putlog "reason: $::errorInfo"} else { putlog "Cast Socket $CastSock created"}</code></pre></div>This will post the channel identifier (what you like to call "socket") when the command is successful, and post the full details on why the command failed when it's not. Not using this info makes your tests pretty much useless, as it tells us absolutely nothing as to what is going on.<br><br>As for stale channel identifiers, my code did not implement any timeout code. As such, we are currently relying on the underlying network layer to change the state of the channel to something like connection failed (and thus triggering tcl to close the channel identifier). Of course, since you keep on trying without any timeout or cleanup-code, you'll eventually run out of resources, pretty much causing the issues you describe.<br><br>A simple timeout implementation, start a timer (preferably using <strong class="text-strong">after</strong>) that just closes the channel identifier after sufficient time has passed. This in turn will destroy any references, including fileevents to this channel identifier.<br><br><br>I have no clue what you are talking about with this:<blockquote class="uncited"><div>Now your examples didn't work either- because they work with the ASSUMPTION that the basic connection handlers follow protocol- which theese do -NOT-</div></blockquote>Are you trying to say that your services does not use http-transactions?<br><br>There is one issue, some http-transactions do not use trailing newlines on the data output, meaning we will not get the last line when using <strong class="text-strong">gets</strong>. Using <strong class="text-strong">read</strong> (properly) when reading the data will solve this issue, yet I still recommend using <strong class="text-strong">gets</strong> while retrieving the headers.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Mar 06, 2009 3:35 pm</p><hr />
]]></content>
	</entry>
	</feed>
