Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Advanced port stuff

 [1/15] from: ptretter::primary::net at: 4-Jan-2001 21:08


I know I may not get an answer to this unless it falls on some real REBOL gurus. However, here goes... I got a series of port schemes each assigned to a unique word. In turn I have appended these port assignments into a block called waitports. When I probe waitports I get their repective object datatype structures. My questions is how do I determine which literal words are these objects referencing? Paul Tretter

 [2/15] from: al:bri:xtra at: 5-Jan-2001 16:31


Paul wrote:
> I know I may not get an answer to this unless it falls on some real REBOL
gurus. However, here goes... I got a series of port schemes each assigned to a unique word. In turn I have appended these port assignments into a block called waitports. When I probe waitports I get their repective object datatype structures. My questions is how do I determine which literal words are these objects referencing?
>> o: make object! [
[ w: 'o [ m: 123 [ ]
>> o/w
== o
>> t: get o/w >> probe t
make object! [ w: 'o m: 123 ] I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [3/15] from: rebol:techscribe at: 4-Jan-2001 22:26


Hi Paul, 1. Andrew already pointed out a workable solution.
> how do I determine which literal words are these objects referencing?
2. The objects do not reference the words. The words reference the objects. It's important to keep these things straight. 3. Your question bothers me. Why do you need to know which words reference these objects? I suspect that there may be a conceptual bug involved in your question. I.e. a more (REBOLlish) elegant = simpler solution may prevent this question from coming up altogether. What do you think? Elan Paul Tretter wrote:

 [4/15] from: al:bri:xtra at: 5-Jan-2001 21:28


Elan wrote:
> 3. Your question bothers me. Why do you need to know which words reference
these objects? I suspect that there may be a conceptual bug involved in your question. I.e. a more (REBOLlish) elegant = simpler solution may prevent this question from coming up altogether. I'd agree with this. It sounds like there's a design problem in the script as the problem sounds confused. Usually if you can write clearly what the problem is, the Rebol code becomes immediately apparent, as Rebol script "surfaces" in the description of the problem. For example, in my earlier emails about the 'Fun function, where Ladislav pointed out, IIRC, that 'fun needed to exclude Arguments--the rebol script to solve the problem "surfaced" as: Locals: exclude Locals Spec I hope that helps! Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [5/15] from: philip:hayes:btcellnet at: 5-Jan-2001 8:53


Can you expand upon this ? Particularly 'which literal words'

 [6/15] from: ptretter:primary at: 5-Jan-2001 8:53


Ok, so far the answers relating to objects I have all ready known but appreciate your input. I think the complexity is that these objects are port objects that have been added to a block. The block is referenced by the word 'waitports. waitports contains the port objects which are appended to it dynamically as the script runs. For example if waitports contained three port objects - then the following:
>> print waitports
?port? ?port? ?port? ok print now this:
>> print first waitports
irc-open-port now I try moving the index to get the literal of the second port since the first port responded correctly: waitports: next waitports
>> print first waitports
?port? I notice that it shows only one ?port? instead of two and it didnt give me the literal word referencing that port object. Is this a bug or is there new information we need to document regarding objects appended to blocks when they are port datatypes. As you can see this script deals with IRC. The first port in the block is the port object for the irc server itself. The next port and subsequent ports are for dcc ports that are dynamically added to the block while the script is online and active on irc. These dcc ports objects are assigned to the nickname of the user on irc (since each user must have a unique nickname on the irc network). This assignment was done with this function in my script: dcc-parser: does [ if secured [ if dcc-chat-flag [ dcc-client: message/nick dcc-client-port: message/dataparse/5 dcc-connect: [ scheme: 'tcp host: dcc-ip port-id: to-integer dcc-client-port ] either error? error-dcc-open-client: try [dcc-open-client: open/lines/direct/no-wait dcc-connect][ error-dcc-open-client: disarm error-dcc-open-client error-proc error-dcc-open-client ][ insert dcc-open-client read %help.txt dcctemp: :dcc-client dcctemp: make set-word! :dcctemp mold dcctemp :dcc-open-client append waitports get make word! copy :dcc-client dcc-chat-flag: off dcc-client-port: dcc-connect: none ] ] ] ] message/nick above is the object containing the nickname of the user from the ircparser function (not listed). As you can see from the third line from the bottom of the function the port is appended to waitports. The script does everything I want it to do. However, I am getting ready to add more code to this function to perform some logic based on the literals within waitports block. Thats is what Im having trouble determining since its dynamically assigned during execution. Hope this helps. Paul Tretter

 [7/15] from: ptretter:primary at: 5-Jan-2001 13:18


When I say literal words I mean the actual set-word! that is used to define the port object. That is what I am trying to retrieve from the waitports block. For example when a user on irc initiates a dcc chat session with my script it takes their ip address and port and opens a connection (port) to that client. It must be able to monitor the incoming data so what I did was create a set-word! datatype from the users nickname on IRC and assign the dcc port object to that set-word! I then append that to the waitports block so I can monitor incoming data on that port. For example if my nick on IRC is REBMASTER then my script would make a set-word! datatype from REBMASTER so that I could assign it to the port scheme of the actual user REBMASTER. Then it would insert REBMASTER port object into the waitports block. So in turn waitports would contain all ports including the main irc-open-port that I connected the script to IRC with in the first place. The problem is that when I probe waitports I only see IRC-OPEN-PORT and dont see REBMASTER. I do see REBMASTER's object in the block but not the literal word REBMASTER anywhere. However if I do : found? find waitports rebmaster == true Its there but I dont have any other way of see which object is assigned to it or have any idea on how to close that object. Paul Tretter

 [8/15] from: jelinem1:nationwide at: 8-Jan-2001 11:33


www.rebol.org/advanced/multisession.r Alternatively you could look at the code of my MUD: Monsters and Treasures. It's sitting on a web/ftp site, I've just never thought of simply giving out the address (in http form) for people to view it. In particular, the mod.players module handles all the port stuff. http://members.home.net/michael1356/files/montreas/ - Michael Jelinek Paul Tretter <[ptretter--primary--net]>@rebol.com on 01/08/2001 09:07:18 AM From: "Paul Tretter" <[ptretter--primary--net]>@rebol.com on 01/08/2001 09:07 AM Please respond to [rebol-list--rebol--com] Sent by: [rebol-bounce--rebol--com] To: <[rebol-list--rebol--com]> cc: Subject: [REBOL] Re: Advanced port stuff I believe what your doing with MUD is very similiar with what Im doing in my script. I got alot of help with this on IRC from other programmers where I was able to do this in realtime and post results in the channel and get good feedback. I could not locate the multisession.r script from the site. If anyone has it please forward to me as Im curious about the use of ports within a block. Paul Tretter

 [9/15] from: g:santilli:tiscalinet:it at: 8-Jan-2001 19:05


Hello [jelinem1--nationwide--com]! On 08-Gen-01, you wrote: j> 'waitports with a client object (ie a "player" in my MUD). It j> would be nice if the 'port objects could point to (ie j> reference) the associated client object, but alas it doesn't j> and I haven't been brave enough to overuse one of the 'port j> elements to do this (don't even know if I COULD). SO, I create If they are TCP ports, you can use PORT/LOCALS quite safely. It is used by scheme handlers to store data, so REBOL won't touch that. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [10/15] from: rebol:techscribe at: 8-Jan-2001 11:23


Hi Paul, if I understand the documentation for dispatch correctly, then it does exactly what you are looking for. (See the pdf version of the /Core manual for a slightly more detailed explanation). Take Care, Elan

 [11/15] from: al:bri:xtra at: 7-Jan-2001 9:23


Paul wrote:
> I think the complexity is that these objects are port objects that have
been added to a block. The block is referenced by the word 'waitports. waitports contains the port objects which are appended to it dynamically as the script runs. For example if waitports contained three port objects - then the following:
> >> print waitports > ?port? ?port? ?port? > > ok print now this: > >> print first waitports > irc-open-port > > now I try moving the index to get the literal of the second port since the
first port responded correctly:
> waitports: next waitports > > >> print first waitports > ?port? > > I notice that it shows only one ?port? instead of two and it didnt give me
the literal word referencing that port object. Is this a bug or is there new information we need to document regarding objects appended to blocks when they are port datatypes. I think you may have an unseen space lurking in your script. I tried out your example using ports on local files like this:
>> p1: open %f1.txt >> p2: open %f2.txt >> p3: open %f3.txt >> waitports: make block! 0
== []
>> append waitports reduce [p1 p2 p3]
== [ make object! [ scheme: 'file host: none port-id: none user: none pass: none ...
>> print waitports
?port? ?port? ?port?
>> print first waitports
?port?
>> waitports: next waitports
== [ make object! [ scheme: 'file host: none port-id: none user: none pass: none ...
>> print first waitports
?port? Note that I couldn't duplicate this:
> ok print now this: > >> print first waitports > irc-open-port
I suspect that "waitports" might be: "wait ports" in your script. Note the space between "wait" and "ports". I think it would be a good idea to call 'waitports something else more descriptive of it's purpose.
> However, I am getting ready to add more code to this function to perform
some logic based on the literals within waitports block. Thats is what Im having trouble determining since its dynamically assigned during execution. There are no "literals" inside the waitports block. According to my example, there are only port! objects inside it. Note that 'p1, 'p2 and 'p3 still refer to their respective values.
> dcctemp: :dcc-client > dcctemp: make set-word! :dcctemp > mold dcctemp :dcc-open-client
What's the intent of the above line? It seems to do nothing.
> append waitports get make word! copy :dcc-client
I'm fairly sure the above line is where your problem lies.
> dcc-chat-flag: off > dcc-client-port: dcc-connect: none
Perhaps better is something like: Nicks: make block! 0 ; in your initialisation code. Nick: to word! message/nick set Nick dcc-open-client ; Note lack of apostrophe {'} append Nicks Nick The above assumes that 'message/nick fits in a subset of valid rebol words. I hope that helps! Andrew Martin Learning something new each and every day... ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [12/15] from: jelinem1:nationwide at: 8-Jan-2001 7:56


You might try checking out multisession.r on REBOL.org. I THINK it does this (associating literal words to port objects in a 'waitports list)... If not, what you might have to do is either do a 'find within the list of 'waitports, or keep a synchronized list (block) of literal words to match the 'waitports list. BTW to want this task does not imply that you have badly designed code IMO - or even that a simpler solution exists. I do the same 'waitports list scheme in my MUD and given the complexity of the desired task I see no way around it. Actually, what I do in the MUD (and I mention this because you may want to do this also) is associate each 'port object in 'waitports with a client object (ie a "player" in my MUD). It would be nice if the 'port objects could point to (ie reference) the associated client object, but alas it doesn't and I haven't been brave enough to overuse one of the 'port elements to do this (don't even know if I COULD). SO, I create a reference to the associated 'port object from the client object when the port is created. Then I perform an "ugly" loop through the client list to find the matching client for a given 'port. - Michael Jelinek Paul Tretter <[ptretter--primary--net]>@rebol.com on 01/05/2001 08:53:46 AM From: "Paul Tretter" <[ptretter--primary--net]>@rebol.com on 01/05/2001 08:53 AM Please respond to [rebol-list--rebol--com] Sent by: [rebol-bounce--rebol--com] To: <[rebol-list--rebol--com]> cc: Subject: [REBOL] Re: Advanced port stuff Ok, so far the answers relating to objects I have all ready known but appreciate your input. I think the complexity is that these objects are port objects that have been added to a block. The block is referenced by the word 'waitports. waitports contains the port objects which are appended to it dynamically as the script runs. For example if waitports contained three port objects - then the following:
>> print waitports
?port? ?port? ?port? ok print now this:
>> print first waitports
irc-open-port now I try moving the index to get the literal of the second port since the first port responded correctly: waitports: next waitports
>> print first waitports
?port? I notice that it shows only one ?port? instead of two and it didnt give me the literal word referencing that port object. Is this a bug or is there new information we need to document regarding objects appended to blocks when they are port datatypes. As you can see this script deals with IRC. The first port in the block is the port object for the irc server itself. The next port and subsequent ports are for dcc ports that are dynamically added to the block while the script is online and active on irc. These dcc ports objects are assigned to the nickname of the user on irc (since each user must have a unique nickname on the irc network). This assignment was done with this function in my script: dcc-parser: does [ if secured [ if dcc-chat-flag [ dcc-client: message/nick dcc-client-port: message/dataparse/5 dcc-connect: [ scheme: 'tcp host: dcc-ip port-id: to-integer dcc-client-port ] either error? error-dcc-open-client: try [dcc-open-client: open/lines/direct/no-wait dcc-connect][ error-dcc-open-client: disarm error-dcc-open-client error-proc error-dcc-open-client ][ insert dcc-open-client read %help.txt dcctemp: :dcc-client dcctemp: make set-word! :dcctemp mold dcctemp :dcc-open-client append waitports get make word! copy :dcc-client dcc-chat-flag: off dcc-client-port: dcc-connect: none ] ] ] ] message/nick above is the object containing the nickname of the user from the ircparser function (not listed). As you can see from the third line from the bottom of the function the port is appended to waitports. The script does everything I want it to do. However, I am getting ready to add more code to this function to perform some logic based on the literals within waitports block. Thats is what Im having trouble determining since its dynamically assigned during execution. Hope this helps. Paul Tretter

 [13/15] from: philip:hayes:btcellnet at: 8-Jan-2001 14:23


why not simply assign the port-id to an arbitrary variable and walkthru the port array ?

 [14/15] from: ptretter:primary at: 8-Jan-2001 8:52


Actually what I am currently doing is assigning any dcc ports to a word that matches the users nick and then inserting that port scheme into waitports. This is done after the script is initially executed as dcc ports are opened and closed. My waitports block contains all ports to be opened. First port in the block is actually the irc port itself for connecting the irc bot to the server. which I can find by doing the following: find waitports 'irc-open-port But if I want to find one of the dynamic dcc ports its a bit more complicated. I would have to know the nick of the user that opened the port since this name is used as the word to assign that port scheme to. For exampe if user "Somenick" requests a dcc session with the bot then the bot will create a port and insert "Somenick" within the waitports block. Now if I try to find this "Somenick" dcc port here is the strange part: find waitports 'somenick I will get an error that somenick as no value. But if I do: find waitports somenick I will get the object spec that is the value of "somenick". Probing waitports never reveals this "somenick" set-word datatype anywhere. Find is the only way I have come to reveal it and you must know the set-word datatype that your looking for. Actually, I found solutions to make the whole thing work with opening and properly closing the ports, etc.. It works very nicely. I just wish probe would reveal everything within the block. As you may assume troubleshooting was a real pain. Paul Tretter P.S. the reason I do this assignment to the users nick is because I wont to ensure no unnecessary ports are opened and that dcc flooding is minimized. Since IRC only allows unique nicks this ensures that each user has one dcc session open at a time. They can open another under a different nick but if they open another under their same nick it closes the previous one.

 [15/15] from: ptretter:primary at: 8-Jan-2001 9:07


I believe what your doing with MUD is very similiar with what Im doing in my script. I got alot of help with this on IRC from other programmers where I was able to do this in realtime and post results in the channel and get good feedback. I could not locate the multisession.r script from the site. If anyone has it please forward to me as Im curious about the use of ports within a block. Paul Tretter