package com.abblcg;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class RegServer {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
ServerSocket ss = new ServerSocket(10000);
Socket s = ss.accept();
String ip = s.getInetAddress().getHostAddress();
System.out.println("ip:" + ip);
InputStream is = s.getInputStream();
byte[] bt = new byte[1024];
int len = is.read(bt);
System.out.println(new String(bt,0,len));
/*BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line = null;
while ((line = br.readLine())!=null) {
System.out.print(line);
System.out.println();
}*/
PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
pw.println("<font size=7 color=blue>注册成功</font>");//为什么不能用write?
ss.close();
s.close();
//br.close();
pw.close();
}
}
|
|