This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Sockets support

Old posts that have not been replied to for several years.
Locked
j
jetsoni

Post by jetsoni »

I have modified my eggdrop ( 1.6.8 ) code not to terminate socket when it encounteres blank line and I was just wondering if it is/will be supported some time without modifying/patching code. I needed the modification to get irc2www script working that was supposed to work only with earlier version of eggdrop. It took only little fix in the script to work with this newer release without a flaw.

_________________
http://www.raasu.org/index.php
http://www.pcuf.fi/~linki/

<font size=-1>[ This Message was edited by: jetsoni on 2002-02-19 15:38 ]</font>
g
guppy
eggdrop engineer
Posts: 199
Joined: Mon Sep 24, 2001 8:00 pm
Location: Canada
Contact:

Post by guppy »

Why not send a patch in?

diff -bur old new > patchname.diff on the latest CVS and mail it on in with a desc of the patch and such to patches@eggheads.org

Jeff
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Jetsoni, guppy, I do not oppose a patch of eggdrop's rather strange idea of considering blank lines as "end-of-connection" markers.
The patch proposed here, however, will break many scripts. Personally, I don't mind such a break, but only if the patch brings an improvement and the consequenses are carefully reviewed.
Actually, in the previous century Ernst used a patch which changed the "end-of-line" marker from a blank line to something like "**EOF**".

As a minimum, a patch MUST include a PROPER and WELL DEFINED "end-of-connection" marker. Jetsoni, what marker have you introduced in your patch?

Currently, blank lines are not send to eggdrop's [control]. When a connection terminates, a blank line is send to eggdrop's [control] to mark an "end of connection". Properly written scripts test on this "end-of-connection" marker.

When writing an HTTP script one may encounter the following major headache. HTTP seperates a HTTP head from a HTTP body with a blank line. An eggdrop script, parsing an HTTP POST, will thus have difficulty seperating head and body.
Additionally, lines are only send to eggdrop's [control] after an "end-of-line" marker. HTTP POST's not always contain an "end-of-line".
Subsequently, posted data is not send to eggdrop's [control] and the connection may hang until either part terminates the connection.
(Read http://forum.egghelp.org/viewtopic.php? ... forum=2&11 )
Although ways of circumventing the above are possible, they give major headache and increase CPU usage substantially.

A proposal for a patch is to mimic TCL's sockets behaviour half or fully:

- blank lines do not indicate an "end-of-connection" and are send to eggdrop's [control] like any other line.
- a command to check for an "end-of-connection", something like [eoc $idx], similar to TCL's [eof] command. Return "1" if "end-of-connection", "0" otherwise.
- a command to read a number of bytes from the socket, something like [readidx $idx $numbytes], similar to TCL's [read]. Return "1" upon successfull read, "0" otherwise and leave bytes on the socket.
- commands like TCL's [gets] and [fblocked] may be needed (?).

One may ask: why not use TCL sockets right away?

- By sticking to eggdrop's commands, dependencies on (future changes in) TCL sockets are elimated
- TCL's [fileevent] is only triggered once every 200 ms or so by eggdrop's loop, which makes processing of HTTP's head + body take 2 seconds or more. This may be circumvented by reading all data available on the socket, but is a bit awkward compared to eggdrop's [control].
- eggdrop's commands related to $idx (and not sock#), like [dcclist], [putdcc], [putidx] etc. can still be used in scripts.
- Personal observation: eggdrop is more sensitive to errors/bugs in scripted TCL's sockets (i,e, eggdrop crashes easily when a bug/mistake is made
using TCL's sockets).

<font size=-1>[ This Message was edited by: egghead on 2002-02-20 20:35 ]</font>
j
jetsoni

Post by jetsoni »

On 2002-02-20 18:14, guppy wrote:
Why not send a patch in?

diff -bur old new > patchname.diff on the latest CVS and mail it on in with a desc of the patch and such to patches@eggheads.org

Jeff
I don't have the modified source code anymore, just the binary version. But I think that someone could easily re-create it from the original instructions that were in the irc2www script. There is almost identical lines in the old version and in the new version of the eggdrop source, but in the new version there is less commands needed, because one function didn't exist anymore and I think that it wasn't really necessary in the new version.
j
jetsoni

Post by jetsoni »

On 2002-02-20 18:58, egghead wrote:
Actually, in the previous century Ernst used a patch which changed the "end-of-line" marker from a blank line to something like "**EOF**".

As a minimum, a patch MUST include a PROPER and WELL DEFINED "end-of-connection" marker. Jetsoni, what marker have you introduced in your patch?
The Patch was almost identically to the original Ernst's, I just changed it to work with the new release of Eggdrop. So the marker was the same as in Ernst's script.

I'm not expert coding C, so I didn't try to start guessing anything too complex.
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

The Patch was almost identically to the original Ernst's, I just changed it to work with the new release of Eggdrop. So the marker was the same as in Ernst's script.

I'm not expert coding C, so I didn't try to start guessing anything too complex.
I'm not an eggdrop C-code developer either :smile: If the patch doesn't go beyond the blank line problem, then a few options are possible:

1. Apply Ernst's patch right away: blank lines are sent to eggdrop's [control] without special meaning. In case of an end of connection the **EOF* string (or some other specific string) is sent to eggdrop's [control]

2. Allow for a setting for the end-of-connection marker in eggdrop's config file or in eggdrop.h. If the marker is set to "", eggdrop's current behaviour is retained, otherwise behaviour is as under point 1 above.

3. Prepend to all lines sent to eggdrop's [control] one character e.g. ":". In case of an end-of-connection, a fully blank line is sent.

I agree that (it seems that) the required modification to the C-code is minor. However, I can't judge the implications for existing scripts.
Hopefully the devteam will have a look at it. IMO a patch is really helpful for scripting purposes.

<font size=-1>[ This Message was edited by: egghead on 2002-02-23 10:07 ]</font>
Locked