Eu fiz tudo na R.
stream_processor <- function(host_,port)
con2 <- socketConnection(host=host_, port=port_)
# as non-blocking, may need to loop for input
readLines(con2)
while(isIncomplete(con2)) {
Sys.sleep(1)
z <- unlist(readLines(con2,1000))
write(z, file=paste(make.names(date()),'.stream',sep=''))
}
}