-
public class sent {
public static void main(String[] args) throws IOException {
Socket sc= new Socket("127.0.0.1",10086);
OutputStream os = sc.getOutputStream();
os.write("aaa".getBytes());
os.close();
sc.close();
}
}
public class receive {
public static void main(String[] args) throws IOException {
ServerSocket sc= new ServerSocket(10086);
Socket accept = sc.accept();
InputStream is = accept.getInputStream();
int b;
while((b = is.read()) != -1){
System.out.println((char)b);
}
is.close();
sc.close();
}
}