|
public static void main(String[] args) throws IOException {
|
səhifə | 3/3 | tarix | 16.12.2023 | ölçüsü | 31,01 Kb. | | #180991 |
| 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();
} }
Dostları ilə paylaş: |
|
|