当我尝试通过java连接到我的ruby sinatra服务器时,出现错误NoMethodError: undefined method 'bytesize'
。NoMethodError:未定义的方法`bytesize'Sinatra
这是我的Ruby代码,我怀疑我需要某种方法,它运行在客户端连接,但我不知道:
require 'sinatra'
get '/hello' do
'this page displays hello'
end
get '/' do
'this page is the main page'
end
这里是我的Java应用程序的代码:
private static Socket connect;
private static OutputStream output;
private static InputStream input;
public static void main(String[] args) throws IOException {
System.out.println("Connecting...");
connect = new Socket(InetAddress.getByName("localhost"), 4567);
System.out.println("Connected to: " + connect.getInetAddress().getHostName());
output = new ObjectOutputStream(connect.getOutputStream());
output.flush();
//input = new ObjectInputStream(connect.getInputStream());
System.out.println("Streams ready");
}
正确?西纳特拉应用程序的工作,当你通过浏览器访问它? –
@RossPenman是的,工作完全正常 – Cj1m
你期望在Java代码中会发生什么?你不做任何HTTP请求。你为什么使用ObjectOutputStream? – matt