Muhammad al-xorazmiy nomidagi toshkent axborot texnologiyalari universiteti telekommunikatsiya texnologiyalari


public static void main(String[] args) throws IOException {



Yüklə 31,01 Kb.
səhifə3/3
tarix16.12.2023
ölçüsü31,01 Kb.
#180991
1   2   3
abdumalik2-labarataotiya

public static void main(String[] args) throws IOException {


System.out.println("Client ishga tushdi!");

BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));

DatagramSocket clientSocket = new DatagramSocket();

InetAddress IPAddress = InetAddress.getByName("localhost");

byte[] sendData1;

byte[] sendData2;

byte[] receiveData = new byte[1024];

System.out.print("Konusning yasovchisini kiriting: ");

String l = inFromUser.readLine();

sendData1 = l.getBytes();

System.out.print("Konusning asosi rasiusini kiriting: ");

String r = inFromUser.readLine();

sendData2 = r.getBytes();

DatagramPacket sendPacket1 = new DatagramPacket(sendData1,

sendData1.length, IPAddress, 1234);

DatagramPacket sendPacket2 = new DatagramPacket(sendData2,

sendData2.length, IPAddress, 1234);

clientSocket.send(sendPacket1);

clientSocket.send(sendPacket2);


DatagramPacket receivePacket = new

DatagramPacket(receiveData, receiveData.length);

clientSocket.receive(receivePacket);

System.out.println("SERVERDAN => Konus sirtining yuzi: " + new String(receivePacket.getData(), 0, receivePacket.getLength()));

clientSocket.close();


}

}


Yüklə 31,01 Kb.

Dostları ilə paylaş:
1   2   3




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin