Home   Archive   Permalink



tcp comm

Hi
I was running the example tcp server and client on port 9097. I unblocked the port but it still won't run for the client. I am running both scripts from my pc. Is that wrong? Here is the code
R E B O L [ Title: "Example TCP Server & Client" ]
    
     either all [args: system/options/args find args "-c"] [
         port: open/direct/lines/no-wait tcp://localhost:9097
         args: true
     ][
         listen: open/direct/lines/no-wait tcp://:9097
         wait listen
         port: first listen
         args: false
     ]
    
    view/new win: layout/size [
         backdrop either args [green][red]
         text "type a message then press [ENTER] to send to the green window"
         entry: field [ insert port entry/text focus entry ]
         display: info "" 300x200
         button "quit" [
             close port
             if not args [close listen]
             unview halt
         ]
     ] 320x300
     win/offset: 0x0
     show win
    
     forever [
         wait port
         foreach msg any [copy port []] [
             append display/text join msg newline
         ]
         show display
     ]


posted by:   john       6-May-2014/1:48:45-7:00



I haven't had a moment to go through this code yet. Have you seen:
    
http://business-programming.com/business_programming.html#section-17.4
    
Particularly this example:
    
view layout [ across
     q: btn "Serve"[focus g p: first wait open/lines tcp://:8 z: 1]text"OR"
     k: btn "Connect"[focus g p: open/lines rejoin[tcp:// i/text ":8"]z: 1]
     i: field form read join dns:// read dns:// return
     r: area rate 4 feel [engage: func [f a e][if a = 'time and value? 'z [
         if error? try [x: first wait p] [quit]
         r/text: rejoin [x "^/" r/text] show r
     ]]] return
     g: field "Type message here [ENTER]" [insert p value focus face]
]

posted by:   Nick       8-May-2014/13:18:12-7:00



Hi,
Thanks . I will go over the code you have posted. As Always, thanks.

posted by:   John       8-May-2014/13:34:34-7:00