我打算在rubyonrails应用程序的数据库中运行Python编写的机器学习算法。经过一些研究,我发现了套接字,因此创建了一个Ruby服务器和Python客户机。我在两个不同的命令提示符终端上运行它们。在
下面是Ruby服务器代码:
require "socket"
server = TCPServer.open(2000)
loop {
client = server.accept
client.puts(Time.now.ctime)
client.puts "Closing the connection. Bye!"
client.close
}
下面是Python客户端代码:
^{2}$我不明白问题出在哪里。请协助。在
对于我上面的问题给出了深刻的回答,代码Ruby服务器和Python客户机应该如下所示。在
对于Ruby服务器:
对于Python客户机:
^{pr2}$Ruby中TCPServer类的open()方法接受两个参数。第一个是主机名,第二个是端口,即
相关问题 更多 >
编程相关推荐