4-04:私有IP通过网关代理上网的原理:
package
import
java.io.IOException;import
java.io.InputStreamReader;import
java.net.ServerSocket;import
publicclass
main(String[] args) IOException {
new
"welcome login my server machine!"
newnew
/* byte[] btf=new byte[1024]; int len=ips.read(btf);*/ String say=br.readLine(); System..println(say); br.close(); s.close(); ss.close(); }
4-06:
服务器端程序:
frame;
import
java.net.ServerSocket;import
publicclass
publicstaticvoid
ServerSocket ss; { ss = ServerSocket(9000); (){ Socket s=ss.accept(); Thread( Servicer(s)).start(); } } (IOException e) { System..println(<FONT face=""" color="#2a00ff">"服务器关闭<FONT face=""" color="#2a00ff">"
}package
import
java.io.InputStream;import
java.io.OutputStream;import
java.net.Socket;
Servicer Runnable {
privatesnull
public
super
thiss
run() {
try
s
s
"welcome login my server machine!"
newtrue
newnew
whiletrue
if"quit"
snull
out
newnew
"处理后<FONT face=""" color="#2a00ff">:"
catch
out"一个客户端同服务器断开连接<FONT face=""" color="#2a00ff">"
}<FONT face=""">