r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Core] Discuss core issues

BrianH
2-Jun-2007
[8233x2]
What Maxim is describing is the CHECK clause proposal I made a few 
years ago. See here:
http://www.colellachiara.com/soft/Misc/parse-rep.html
This collection was made last year, but I first proposed CHECK years 
ago (calling it IF at the time), for the previous round of proposals.
Henrik
5-Jun-2007
[8235x2]
I'm working on reducing memory consumption on my little database 
and was wondering if stats is reading out the total memory usage 
correctly or if Windows XP's job list is. I can do a script that 
gradually eats up 100 MB memory and then the memory is recycled, 
when I ask for it. 'stats then prints about 15 MB used, which is 
fine, but the job list reads out about 100 MB still used and it stays 
there. Right now it reads about 104.656 KB used, while stats prints 
15588191 bytes. This is in a stopped console. Recycling more doesn't 
help.


I've even seen the job list memory jump up 10-20 MB once when recycling. 
Which one is reading out the correct number?
I think I get it. If I run the script again, the job list does not 
show memory usage to be above 104 MB until stats also show above 
104 MB. So Windows must be keeping inactive memory around for the 
task.
Chris
5-Jun-2007
[8237]
I've made a small change to the %filtered-import.r script -- it should 
now properly handle the 'opt modifier:

>> import [][test: opt string!]
== [test none]
>> import [test ""][test: opt string!]
== [test none]
>> import [test ""][test: string!]
== none

This last one could be considered unexpected?
Louis
6-Jun-2007
[8238x2]
I'm trying to learn how to make tcp servers, reading this rebol doc: 
file:///C:/SDK/docs/core23/rebolcore-13.html#section-14

Why am I getting this error:

>> listen: open tcp://:8001
** Access Error: Error opening socket listen port
** Near: listen: open tcp://:8001

Turning the firewall off does not help.
This seems to work:

>> listen: open tcp://localhost:8001

But the docs specifically say:


Notice that you do not supply a host name, only a port number. This 
type of port is called a listen port. The system now accepts connections 
on port number 8001.

Is this a mistake in the docs?
Sunanda
6-Jun-2007
[8240]
Henrik -- I think Gabriele said recently that REBOL *never* hands 
back memory to the opsys. So, although, REBOL's stats are reporting 
in-use memory, they are not telling you all the still reserved memory.
I think that explains your observations.
sqlab
6-Jun-2007
[8241x2]
Lous:

your port  is already opened either by an opther application or by 
this rebol instance as you can connect to.

So either use an other port number or close your listen socket before 
opening again
sorry  Lous --> Louis
Henrik
6-Jun-2007
[8243]
sunanda, I see, thanks
Will
6-Jun-2007
[8244x2]
anyone else thinks this would be useful? 
reduce 'abc/'def/(1 + 2)
instead of
to path! reduce ['abc 'def (1 + 2)]
but you can't do
abc/'def/(1 + 2)
so maybe a new repath function:
repath abc/'def/(1 + 2)
?
Louis
6-Jun-2007
[8246]
sqlab, thanks. But no matter what number I use it is not working 
for me.
Anton
6-Jun-2007
[8247]
Will, I think so.
Oldes
6-Jun-2007
[8248]
Louis:   if you:

open tcp://localhost:8001


you do not open port for listening but for reading/writing as for 
example:

p: open tcp://www.rebol.com:80


so if you can open such a port on localhost, you MUST have something 
what listens on such a port
Anton
6-Jun-2007
[8249]
Oh yes, Oldes is right.

Remove "localhost" if you want to be a server. The docs are right.

Your next script, the rebol client that connects to this server, 
*will* specify localhost.
Louis
6-Jun-2007
[8250]
Anton, Olds, sqlab, thanks for the help.

Here I paste directly from the docs:

>> server-port: open/lines tcp://:4321
** Access Error: Error opening socket listen port
** Near: server-port: open/lines tcp://:4321
>>


Could there be something wrong with the way XP is set up that is 
causing this?
btiffin
6-Jun-2007
[8251x2]
Louis;  Is something alreasy open on 4321...try another port...
Never mind...just read back through the thread.  Time for sleep. 
 :)  Good luck.
Will
6-Jun-2007
[8253]
Anton: you mean we need a repath function?
Louis
6-Jun-2007
[8254]
btiffin and sqlab, it turns out that you both suggested the right 
thing. I must have a lot of ports being used already on my computer. 
Since you both thought this is what was wrong. I just kept on trying 
port numbers until finally...it worked! Thank you both very much! 
 Thanks to all of you that helped me, this day has ended pretty good! 
 Having endured the earlier aggravation, the good feels even better 
than usual.


So many ports being open does make me wonder why, however. That seems 
a little dangerous to me.
Ammon
6-Jun-2007
[8255]
Louis, here's a windows tool that will let you see what ports are 
open and what application is listening on the ports.

http://www.nirsoft.net/utils/cports.html
Oldes
6-Jun-2007
[8256]
or use this http://www.microsoft.com/technet/sysinternals/utilities/TcpView.mspx
Louis
6-Jun-2007
[8257x2]
Ammon and Oldes, thanks. I'll check them out.
87 ports open---most of them by REBOL.  The script was working, but 
I didn't realize it because no window was opening.  This was the 
result of working too many hours without enough sleep. It just doesn't 
pay.  We get more done in the long run if we stop and play or sleep 
when we should. Thanks again, you guys, for all the help; very much 
appreciated!
Gregg
6-Jun-2007
[8259]
Will, a REPATH, AS-PATH, or DO-AS-PATH kind of thing would be very 
handy at times.
Louis
6-Jun-2007
[8260]
Does the following line only work with e-mail?

system/options/binary-base: 64  ; best binary encoding
Oldes
6-Jun-2007
[8261]
>> probe as-binary "test"
#{74657374}
>> system/options/binary-base: 2
>> probe as-binary "test"
2#{01110100011001010111001101110100}
>> system/options/binary-base: 64
>> probe as-binary "test"
64#{dGVzdA==}
Louis
6-Jun-2007
[8262]
Thanks, Oldes!
Louis
7-Jun-2007
[8263x6]
Good progress, then stuck again. I can get one file transferred, 
but I don't know how to transfer the following files. This is the 
server (put it in an empty folder): 

rebol []

print ["This program RECEIVES files sent by send-files-tcp." newline]
port-num: request-text/title/default "Port Number: " "2006"
url: to-url rejoin ["tcp://:" port-num]
received-file: copy first open/binary url
write %file-names decompress received-file
files: load %file-names
foreach file files [

    received-file: copy url ;<======== HOW DO I FEED IN THE NEXT FILE?
    write/binary file received-file
    print ["Successfully received file: " file]
]

ask "The files transfer is complete. Press <Enter> to close."
This is the client; put it in the folder containing the files you 
want to send.

rebol []
ip: request-text/title/default "IP Address: " "localhost"
port-num: request-text/title/default "Port Number: " "2006"
url: to-url rejoin ["tcp://" ip ":" port-num]
system/options/binary-base: 64  ; best binary encoding


print ["This program SENDS all files in its folder to receive-files-tcp." 
newline]
print "NOTE: receive-files-tcp must be running on the remote"
print ["computer before starting this program." newline]

files: read %. ; Note that 'files is a block of file names.
save %file-names files
server: open url

insert server compress as-binary read/binary %file-names ;send file 
names
file-block: []
foreach file files [
    if not find file "/" [insert file-block file] ;remove folders
]
files: file-block
foreach file files [
    insert server compress as-binary read/binary file
    print ["Successfully sent file: " file]
]
close server

ask [newline "The files transfer is complete. Press <Enter> to close."]
The design is to place the server in the folder on the computer to 
which you want to transfer files.  Place the client in the folder 
on the other computer containing the files you want to transfer.
Start the server first, then the client, and file transfer should 
be automatic.
....that is if I can get it to work...with your kind help.
It actually needs View to run, but I put it here because the question 
is Core related.
Geomol
7-Jun-2007
[8269x4]
Louis, I think, your problem is, that you only operate with one port. 
When you define a listen port in REBOL, you receive a port from that. 
This new port can be used to receive the file. Something like:

listen-port: open/lines join tcp://: port-num
wait listen-port
talk-port: first listen-port
file: first talk-port
close talk-port
wait listen-port
...


(I haven't tested this code. It's free from a similar program, I 
made in the past.)
Play around with a very simple test, where you do it manually between 
2 REBOL sessions. This way you get a feel for it and can made your 
program to work.
server example:

listen-port: open/lines tcp://:8080
wait listen-port
p: first listen-port
file: load first p
close p
write/binary %file.r debase first file
close listen-port

client example:

p: open/lines tcp://127.0.0.1:8080
insert p remold [enbase read/binary %hokus-pokus.r]
close p
I just tried these examples, and they works. To send more files, 
you should loop the server from the wait to the write, both included.
Louis
7-Jun-2007
[8273]
Geomol, thanks!  I'll experiment with your examples, and report back. 
But it will be awhile, as I'm out of time right now.
Oldes
10-Jun-2007
[8274x3]
as current path-thru function is not working with queries and port 
numbers, and it's not part of core at all, what do you say about 
using this imporved version (which I'm already using for couple of 
years):

path-thru: func [
    "Return a path relative to the disk cache."
    url /local purl
][
    if file? url [return url]
    if not all [purl: decode-url url purl/host] [return none]

    if all [string? purl/target find purl/target #"?"] [replace purl/target 
    "?" "_query_"]
    rejoin [
        view-root/public slash
        purl/host

        either none? purl/port-id [""] [join "_atport_" purl/port-id] slash
        any [purl/path ""] any [purl/target ""]
    ]
]

so:

>> path-thru http://us.maps2.yimg.com/us.png.maps.yimg.com/png?v=3.52&t=m&x=3&y=0&z=16

== %/D/view/public/us.maps2.yimg.com/us.png.maps.yimg.com/png_query_v=3.52&t=m&x=3&y=0&z=16
aaaa.... this nasty Altme link bug... will it ever be fixed?
And it must be so easy to fix it... it looks that it would be enough 
to increase the Y-size ot the face which is used to cound the size 
of the text link (so it do not breaks)
btiffin
10-Jun-2007
[8277]
How many rebols have written language localization routines?

I'm toggling back and forth between external heaps and in-code strings
I've got a RebGUI widget...


lang-text {en "This is the english" fr "C'est francais" it "Don't 
know any italian"}

meaning a translator will have to get dirty in code edits (or send 
to coder) or use

text (lang "SomekindaKey")

where lang is some func that having read some file, selects the string 
key by lang type...
lang-type being buried somewhere in locale*


How often is a REBOL translator a non-programmer?  I find external 
text to be a pain when
coding.  But...it lets non-coders help with translations.


In particular, I only have about 10 or so screens that could be translated. 
 Ashley's

builtin localization nicely handles all the GUI stuff.  I'm leaning 
toward in-code strings.
[unknown: 9]
10-Jun-2007
[8278]
Qtask using a huge database for all languages...
btiffin
11-Jun-2007
[8279]
On the fly translation?  Or work by coders?  Or a text heap?  :)

I guess I'm just looking for advice, but I'm travelling down the 
in-code multi-language
string path.
Gabriele
11-Jun-2007
[8280x3]
my approach is: preprocess the code to identify values that need 
translations (not only strings, any value can be language-dependent)
so if you have     text "Some string"
you add     text #l "Some string"