本帖最后由 闪亮未来 于 2015-3-15 22:34 编辑
- import java.io.*;
- import java.net.*;
- class TcpClient
- {
- public static void main(String[] args)throws Exception
- {
- Socket s=new Socket("192.168.1.254",10001);
- OutputStream out=s.getOutputStream();
- out.write("ge men lai le".getBytes());
- s.close();
- }
- }
- class TcpServer
- {
- public static void main(String[] args)throws Exception
- {
- ServerSocket ss=new ServerSocket(10001);
- while (true)
- {
- Socket s=ss.accept();
- String ip=s.getInetAddress().getHostAddress();
- System.out.println("ip:"+ip);
- InputStream in=s.getInputStream();
-
- byte[] buf=new byte[1024];
- int len=in.read(buf);
- System.out.println(new String(buf,0,len));
- s.close();
- }
- }
- }
复制代码
实在没办法就完全用了老师的代码运行一下,结果还是这样,是怎么回事,客户端发送一段信息给服务端,客户端的dos就这样了
|
|