- 187 名前:デフォルトの名無しさん mailto:sage [02/04/23 16:13]
- 俺も参加。
前スレ839のproxyを縮めてみた。 import java.net.*;import java.io.*;class P{public static void main(final String a[])throws Exception{ServerSocket s=new ServerSocket(a.length>2?Integer.parseInt (a[2]):8080);for(;;){Socket n=s.accept(),o=new Socket(a[0],Integer.parseInt(a[1] ));new P(o.getInputStream(),n.getOutputStream());new P(n.getInputStream(),o .getOutputStream());}}P(final InputStream i,final OutputStream o){new Thread(new Runnable(){public void run(){try{for(int d;(d=i.read())!=-1;)o.write(d);i.close( );o.close();}catch(Exception e){}}}).start();}}
|

|