zoukankan      html  css  js  c++  java
  • TCPSocket TCPServer & TCPClient .java

    TCPServer:

     1 import java.net.*;
     2 import java.io.*;
     3 
     4 public class TCPServer{
     5     public static void main(String[] args) throws Exception{
     6         ServerSocket ss = new ServerSocket(8888); 
     7         Socket sk = ss.accept();
     8         System.out.println("Client Connected!");
     9         InputStream is =sk.getInputStream(); 
    10         DataInputStream dis = new DataInputStream(is);
    11         String s = dis.readUTF();
    12         System.out.println(s); 
    13     }
    14 }

    TCPClient:

     1 import java.net.*;
     2 import java.io.*;
     3 
     4 public class TCPClient{
     5     public static void main(String[] args) throws Exception{
     6         Socket cl = new Socket("127.1.1.0", 8888); 
     7         OutputStream os =cl.getOutputStream(); 
     8         DataOutputStream dos = new DataOutputStream(os);
     9         dos.writeUTF("I LOVE U!!");
    10     }
    11 }
  • 相关阅读:
    工具安装
    Windbg调试
    SQL学习
    Pwnable小结
    how2heap总结
    堆利用小结
    栈溢出利用小结
    格式化字符串利用小结
    python 节假日爬取
    selenuim学习
  • 原文地址:https://www.cnblogs.com/humanchan/p/3020858.html
Copyright © 2011-2022 走看看