gui chuoi
Trang Máy Chủ :
import java.io.*;
import java.net.*;
class TCPSC
{
public static void main(String[] args) throws Exception
{
int port = 2812;
ServerSocket server = new ServerSocket(port);
Socket client = server.accept();
BufferedReader br = new BufferedReader(new
InputStreamReader(client.getInputStream()));
PrintWriter pw = new PrintWriter(client.getOutputStream());
String st = br.readLine();
String kq = XuLy(st);
pw.write(kq + "
");
pw.flush();
pw.close();
br.close();
client.close();
server.close();
}
public static String XuLy(String st)
{
return st.toUpperCase();
}
}
Trang Máy Khách :
import java.io.*;
import java.net.*;
class TCPCC
{
public static void main(String[] args) throws Exception
{
int portS = 2812;
InetAddress ipS = InetAddress.getByName("localhost");
Socket server = new Socket(ipS,portS);
BufferedReader in = new BufferedReader(new
InputStreamReader(System.in));
BufferedReader br = new BufferedReader(new
InputStreamReader(server.getInputStream()));
PrintWriter pw = new PrintWriter(server.getOutputStream());
System.out.print("Nhap chuoi bat ky : ");
String st = in.readLine();
pw.write(st+"
");
pw.flush();
String kq = br.readLine();
System.out.println("Chuoi Hoa : " + kq);
pw.close();
br.close();
server.close();
}
}
Bạn đang đọc truyện trên: AzTruyen.Top