lunlumo #7173(2008/08/17 18:56 GMT) [ Java ] Rating0/0=0.00
Javaがまだの様なので。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
import java.io.InputStream; import java.io.OutputStream; import java.net.Socket; class Echo { Socket socket; OutputStream out; InputStream in; public Echo(String host,int port) throws Exception { socket = new Socket(host,port); out = socket.getOutputStream(); in = socket.getInputStream(); } public void echo(int size,byte[] request) throws Exception { byte[] response= new byte[size]; out.write(request,0,size); out.flush(); in.read(response,0,size); System.out.write(response,0,size); } public void close() throws Exception { socket.close(); } public static void main(String[] args) { try { Echo echo = new Echo(args[0],Integer.parseInt(args[1])); byte[] request = new byte[2048]; int size; while ((size = System.in.read(request)) > 0) { echo.echo(size,request); } echo.close(); } catch(Exception ex) { ex.printStackTrace(); } } }
Rating0/0=0.00-0+
[ reply ]
lunlumo #7173() [ Java ] Rating0/0=0.00
Javaがまだの様なので。
Rating0/0=0.00-0+
[ reply ]