这是我按照视频写的服务端代码
import java.net.*;
import java.io.*;
class N17
{
public static void main(String[] args) throws Exception
{
//服务端
ServerSocket serso=new ServerSocket(11000);
Socket so=serso.accept();
sop(so.getInetAddress().getHostAddress());
InputStream in=so.getInputStream();
byte[] by=new byte[1024];
int i=in.read(by);
sop(new String(by,0,i));
PrintWriter pw=new PrintWriter(so.getOutputStream(),true);
pw.println("客户端您好");
so.close();
serso.close();
}
public static void sop(Object obj)
{
System.out.println(obj);
}
}
|