//***Client*******//
public static void main(String[] args) {
Socket socket;
InetAddress address;
DataOutputStream os;
try {
address = InetAddress.getByName("127.0.0.1");
socket = new Socket(address, 20000);
os = new DataOutputStream(socket.getOutputStream());
os.writeBytes("helllo");
os.close();
socket.close();
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//***Server*******//
public static void main(String[] args) {
ServerSocket serverSocket;
InetAddress serverAddress;
DataInputStream is;
try {
serverAddress = InetAddress.getByName("127.0.0.1");
serverSocket = new ServerSocket(20000, 10, serverAddress);
Socket client = serverSocket.accept();
is = new DataInputStream(client.getInputStream());
String str = is.readLine();
System.out.print(str);
is.close();
client.close();
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
2 yorum:
Elinize sağlık lakin bide android için olanı gelirse araştıranlar daha memnun kaalır.
Evt olabilir elbette uğraştığım an paylaşırım ;)
Yorum Gönder