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

[REBOL] Re: Problem with try [ open/direct/binary tcp://... ] Re:(4)

From: rebol:svendx:dk at: 3-Oct-2000 0:45

Hello [eventi--nyic--com], Actually you can almost use your original function, you just got to be carefull not to evaluate the error! value. (As Andrew pointed out). Some REBOL values defaults to being evaluated on retrival, functions and errors are examples. Others don't - blocks, etc. to safely pass error values around you could use a colon in front of the word. Here's a slightly modified Connect: Connect: Func [ ip port ] [ error? Gp: try [ Open/direct/binary probe To-url join "tcp://" [ Ip ":" port ] ] if not error? :gp [ insert gp "GNUTELLA CONNECT/0.4^/^/" print to-string data: copy gp ] return :gp ] Note the additional colons and the error? in the second line. Now you can do stuff like: ## error? connect "localhost" 1000 tcp://localhost:1000 == true BTW. I once started on a REBOL implementation of the Gnutella protocol, so if you're interested in some marshalling functions, etc - just let me know... Best regards Thomas Jensen On 02-Oct-00, [eventi--nyic--com] wrote: