403-guruh talabsi Po’latov Shoxruxning Tarmoqni dasturlash fanidan



Download 70,47 Kb.
Sana01.01.2022
Hajmi70,47 Kb.
#305308
Bog'liq
polatov2


403-guruh talabsi Po’latov Shoxruxning Tarmoqni dasturlash fanidan

2-labaratorya ishi.

Mavzu: Tarmoqda ko‘poqimlilik asosida ishlovchi dasturni yaratish

Ishning maqsadi:

Java dasturlash tili java.net.*, java.io.* va java.util.* paketlari klasslaridan foydalanib tarmoqda ko‘poqimlilik asosida ishlovchi dasturni yaratish.

Topshiriq:

Talaba laboratoriya ishi uchun shaxsiy topshiriq oladi. Bu topshiriq bo‘yicha talaba tarmoqda ko‘poqimlilik asosida ishlovchi dasturni yaratadi. Har bir talaba uchun shaxsiy topshiriq 2.1- jadvalda berilgan.



Nazariy qism:

Thread klassi yordamida oqim yaratish:

class Multi extends Thread{  

public void run(){  

System.out.println("Oqim ishga tushdi...");  

}  

public static void main(String args[]){  

Multi t1=new Multi();  

t1.start();  

 }  

}  

NATIJA: Oqim ishga tushdi...

Dastur kodi:

Klient qismi:

package client;

import java.io.*;

import java.net.*;

import java.util.Scanner;

public class Client {

public static void main(String[] args) throws Exception

{

String sorov;



String javob1;

String javob2;

Socket clientSocket = new Socket("127.0.0.1", 5522);

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

DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());

Scanner input = new Scanner(System.in);

System.out.println("\nTortburchak tomonlarini kiriting:");

System.out.print("x = ");

float x = input.nextFloat();

System.out.print("y = ");

float y = input.nextFloat();

if (x>0 && y>0)

{

sorov = x+","+y;



outToServer.writeBytes(sorov += "\n");

BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));

javob1 = inFromServer.readLine();

javob2 = inFromServer.readLine();

System.out.println("\nTortburchakning yuzasi: " + javob1);

System.out.println("\nTortburchakning perimetri: " + javob2);

clientSocket.close();

}

else



{

System.out.println("\nTortburchak tomonlari noto'g'ri kiritildi");

}

}

}



Server qismi:

package server;

import java.io.*;

import java.net.*;

import java.util.ArrayList;

public class Server {

static float Yuza(float x, float y)

{

return (x*y);



}

static float Peremetr(float x, float y)

{

return (float)2*(x+y);



}

public static void main(String[] args) throws Exception

{

String clientSorov;



String serverJavob1;

String serverJavob2;

ServerSocket serversocket = new ServerSocket(5522);

while(true)

{

Socket connectionSocket = serversocket.accept();



BufferedReader INPUT = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));

DataOutputStream OUTPUT = new DataOutputStream(connectionSocket.getOutputStream());

clientSorov = INPUT.readLine();

System.out.println("Quyidagilar qabul qilindi: " + clientSorov);

String[] values = clientSorov.split(",");

ArrayList value = new ArrayList<>();

for (String item: values) {

value.add(Float.parseFloat(item));

}

serverJavob1 = Yuza(value.get(0),+value.get(1))+"";



serverJavob2 = Peremetr(value.get(0),+value.get(1))+"";

OUTPUT.writeBytes(serverJavob1+"\n");

OUTPUT.writeBytes(serverJavob2+"\n");

System.out.println("Yuborildi: " + serverJavob1 +" va " + serverJavob2);



}

}

}



Dasaturdan olingan natija


Download 70,47 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish