Direct TCP Data Transfer.

41 views
Skip to first unread message

Hans Schüren

unread,
Sep 8, 2016, 10:07:55 AM9/8/16
to REBOL
Hello ,

its amazing.

i have just checked the example from Rebol Core

direct TCP connection.

It works.

I have opened the program and looked at a port viewing tool that isalways open here.

The port 9999 is listening for input.

Then i closed the program in the code editor and the port remains open.

I closed the process with the windows task manager.

Amazing cool and simple.

I am impressed.


Hans

Gregg Irwin

unread,
Sep 8, 2016, 11:42:15 AM9/8/16
to Hans Schüren
Hi Hans,

HS> its amazing.
HS> i have just checked the example from Rebol Core
HS> direct TCP connection.
HS> It works.

If you use any networking scheme (http, ftp, pop, esmtp), they are all
built on this functionality. You can see all the built in schemes like
this:

>> words-of system/schemes
== [default Finger Whois Daytime SMTP ESMTP POP IMAP HTTP FTP NNTP HTTPS SSMTP]

And you can even see their source code.

>> probe system/schemes/http
make object! [
scheme: 'HTTP
host: none
port-id: 80
...

That's advanced code, though, and you don't need to know anything
about it to read and write against protocols. Just another example of
how much of Rebol is built in Rebol.

--Gregg

Hans Schüren

unread,
Sep 8, 2016, 1:07:47 PM9/8/16
to REBOL, gregg...@gmail.com
Hello Gregg ,

i cannnot close the TCP connection and don't know why ?

The Port 9999 is still open when i close the code in the Editor.

Closing is only possible by closing the Windows Process. The Rebol view exe , which is still open.

I have tried to make a forever loop with break and quit  3 Buttons.

When the connection button is klicked. the other buttons in the forever loop are deactivated.  Not in use.

_____________________________________________________Here is the plain code  :


REBOL [ ]

server-port: open/lines tcp://:9999

forever [
    connection-port: first server-port
    until [
        wait connection-port
        error? try [do first connection-port]
    ]
    close connection-port
]



Here is the code with buttons :
___________________________________________________________________

Rebol [ title: "DIRECT TCP Connection"]

;der Port wird direkt aufgemacht und wartet auf Sendung !


forever [

view layout  [


button 100x100 "TCP Connection" [ server-port: open/lines tcp://:9999                                    
                                    connection-port: first server-port
                                    until [
                                    wait connection-port
                                    error? try [do first connection-port]  ]   ]       
                                        
                                                       
                                     
button 100x100 "CLOSE connection" [break] 
button 100x100 "EXIT" [quit]      

]
]

close connection-port


Remember :  The close and exit buttons are deactivted IF the connection is on !
                    However , the buttons are normal in the forever loop.

sqlab

unread,
Sep 9, 2016, 1:38:52 AM9/9/16
to re...@googlegroups.com
You have to close the listening port with

close server-port

in your program.
> --
> You received this message because you are subscribed to the Google
> Groups "REBOL" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to rebol+un...@googlegroups.com
> <mailto:rebol+un...@googlegroups.com>.
> To post to this group, send email to re...@googlegroups.com
> <mailto:re...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/rebol.
> For more options, visit https://groups.google.com/d/optout.


Hans Schüren

unread,
Sep 9, 2016, 4:12:07 AM9/9/16
to REBOL
Hello sqlab ,

i have tried it but everytime when the normal TCP script is open , the port is open and
not able to close the program.  REBOL.exe

I checked the ports with  Sterjo NETSTALKER
And close the port with a process explorer in windows.
______________________________________________________________________

So i have searched for other TCP Scripts and found it.
I realised that i have to use TWO different scripts for testing.

Script one :

Rebol [ ]

myport: open tcp://:8000
forever [
  print "waiting for connection ..."
  wait myport ; wait as long as no client connects to the server

  ;a client has connected
  print "connection detected"

  connection: first myport

  buffer: make string! 1000
  read-io connection buffer 1000

  print "sending a response"
  probe buffer
  insert connection rejoin ["Received " {"} buffer {"}]

  print "closing the connection"
  close connection]


Script 2 :

Rebol [ ]

try [
myport: open tcp://localhost:8000
insert myport ask "message to send: "
response: make string! 2000
while [
   data: copy myport
][append response data]

print response
        close myport
ask ""
]



WBR
Hans
Reply all
Reply to author
Forward
0 new messages