How to connect two computers using R?

Is it possible to open the communication flow between two R sessions on two different computers?

I use sockets to connect sessions if both are on the same computer. I believe that with two different computers I should try web sockets. httpuvsupports R as a web socket server, but unfortunately I could not find any updated package that supports client web socket in R.

I am not tied to using network sockets. Any solution that allows real-time communication between computers will work.

+4
source share
1 answer

, R.

:

import socket

server <- function(){
  while(TRUE){
    writeLines("Listening...")
    con <- socketConnection(host="localhost", port = 6011, blocking=TRUE,
                            server=TRUE, open="r+")
    data <- readLines(con, 1)
    print(data)
    response <- toupper(data) 
    writeLines(response, con) 
    close(con)
  }
}
server()

:

import socket

client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("localhost", 6011))
while 1:
    data = raw_input ( "Enter text to be upper-cased, q to quit\n" )
    client_socket.send(data)
    if ( data == 'q' or data == 'Q'):
        client_socket.close()
        break;
    else:        
        data = client_socket.recv(5000)
        print "Your upper cased text:  " , data
+1

All Articles