#____________________________________
#Server class'ı (İlk olarak bu class'ı çalıştırın.)
#____________________________________
import java.io.*;
import java.net.*;
public class Server {
static ServerSocket serverSocket;
static Socket socket;
static DataOutputStream out;
public static void main(String[] args) throws Exception{
System.out.println("Starting server...");
serverSocket = new ServerSocket(7777); // port ve ip ayarı (localhost'a ayarlıdır)
System.out.println("Server started...");
System.out.println("Waiting a message...");
socket = serverSocket.accept();
System.out.println("Connection from:" + socket.getInetAddress());
out = new DataOutputStream(socket.getOutputStream());
out.writeUTF("Test mesaj abc");
System.out.println("Data has been sent");
}
}
#____________________________________
#Client class'ı
#____________________________________
import java.io.*;
import java.net.*;
public class Client {
static Socket socket;
static DataInputStream in;
public static void main(String[] args) throws Exception{
System.out.println("Connecting...");
socket = new Socket("localhost",7777);
System.out.println("Connected...");
in = new DataInputStream(socket.getInputStream());
System.out.println("Receiving information...");
String test = in.readUTF();
System.out.println("Message from server:" + test);
}
}
socket,soket,make,multi,player,çok,oyunculu,oyun,game,make,yapmak,yapılır,yapilir,made,create,how,to,java,bukkit,plugin