package TcpDemo02;
import java.io.*;
import java.net.Socket;
public class Send02 {
public static void main(String[] args) throws IOException {
Socket socket = new Socket("192.168.3.125", 10009);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
String line;
while ((line = br.readLine())!=null){
if ("886".equals(line)){
break;
}
bw.write(line);
bw.newLine();
bw.flush();
}
socket.close();
}
}
package TcpDemo02;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;
public class get02 {
public static void main(String[] args) throws IOException {
ServerSocket ss = new ServerSocket(10009);
Socket acc = ss.accept();
InputStream is = acc.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line ;
while ((line = br.readLine())!=null){
System.out.println(line);
}
ss.close();
}
}
|