World: r3wp
[!REBOL3 Schemes] Implementors guide
older newer | first last |
Steeve 10-Jan-2010 [822] | Should be enough make-scheme [ title: "Dns" name: 'dns2 actor: [ read: func [port [port!] /con][ con: open [scheme: 'tcp host: port/spec/host] con/awake: func [event][true] wait [con 5] ;*** timeout 5 secs attempt [get in query con 'remote-ip] ] ] ] >>read dns2://www.rebol.net 216.240.11.203 |
Graham 10-Jan-2010 [823] | Thanks Steeve! |
Steeve 10-Jan-2010 [824x2] | not that i don't need to close the tcp port because it is not (really) opened yet |
not=notice | |
Graham 10-Jan-2010 [826x2] | I didn't open the port either |
Normally one would open the port in the lookup event | |
Steeve 10-Jan-2010 [828] | yep |
Graham 10-Jan-2010 [829x2] | Andreas likes to use funct so no need to declare the locals |
Now how to do a reverse dns lookup?? | |
Steeve 10-Jan-2010 [831] | i don't have any idea how to do that |
Graham 10-Jan-2010 [832x2] | >>read reverse dns2://216.240.11.203 www.rebol.net |
oops ... someone made this group web public! | |
Steeve 10-Jan-2010 [834] | ahah |
Pekr 10-Jan-2010 [835] | we can change it back ... |
Graham 10-Jan-2010 [836x2] | the above was a joke! please ignore |
reverse lookups http://cr.yp.to/djbdns/intro-dns.html | |
Steeve 10-Jan-2010 [838x2] | IIRC we need UDP to do a DNS request. |
So that we can't currently | |
Graham 10-Jan-2010 [840] | Yeah .. just did a packet trace and it's all UDP |
Pekr 10-Jan-2010 [841] | R3 does not contain UDP in networking device low level code? |
Steeve 10-Jan-2010 [842] | not yet |
Graham 10-Jan-2010 [843x3] | Steeve, what's the algorithm for reading data from a port when you don't know how much data is coming down? |
Does each arrival of data trigger a 'read event? | |
and does it append to port/data ? | |
Pekr 10-Jan-2010 [846] | some internals on how low level networking code works - http://www.rebol.net/wiki/TCP_Port_Details |
Steeve 10-Jan-2010 [847] | yep graham |
Graham 10-Jan-2010 [848x2] | # Setup the IO-request data and length fields. Data is the buffer tail position. Length is the buffer space available from above. Clear the actual field. |
so it does an append | |
Steeve 10-Jan-2010 [850] | but don't forget to execute a [read port] each time you received a packet , to be able to receive the futher one. |
Graham 10-Jan-2010 [851] | so you need to do a read port inside the read event? |
Steeve 10-Jan-2010 [852] | yep |
Graham 10-Jan-2010 [853] | all this word overloading drives me crazy! |
Steeve 10-Jan-2010 [854] | packet are append to port/data but the index is not moved |
Graham 10-Jan-2010 [855x2] | eh? |
so how to read until there is no more data ? | |
Steeve 10-Jan-2010 [857] | no "eh?" me !!! :-) |
Graham 10-Jan-2010 [858] | so the index is used by ?? |
Steeve 10-Jan-2010 [859] | there is no way to know how much packets can be received. Your protocol has to send this info, if not you're tricked |
Pekr 10-Jan-2010 [860] | why should every data be read first? Why is not 'read even triggered on new data arrival = change of buffer size? |
Steeve 10-Jan-2010 [861] | actually the read function ask to the server to send the next packet to the client, if any. You may receive a packet (event read triggered) or not. |
Graham 10-Jan-2010 [862x3] | Do we need to clear the port data after a read ? |
or before a read ? | |
eg. copy port/data clear port/data read port ? | |
Steeve 10-Jan-2010 [865x2] | you do as you want |
the packet is added to port/data | |
Graham 10-Jan-2010 [867] | so if we copy port/data read port copy port/data .. we will get duplicate data ? |
Steeve 10-Jan-2010 [868] | yes |
Graham 10-Jan-2010 [869x2] | ok. |
so no more data is appended to the port/data until we ask for it using a read port | |
Steeve 10-Jan-2010 [871] | it's your duty to clear or remove/part data in the buffer |
older newer | first last |