Giter VIP home page Giter VIP logo

datacommunication's Introduction

data-communication

Client Kodları:

package socketapp;

import java.io.; import java.net.;

public class client {

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

 public static void islem() throws UnknownHostException, IOException {
      Socket socket = null;
      PrintWriter out = null;
      BufferedReader in = null;
      String deger;
      try {           
           socket = new Socket("37.155.9.77");
      } catch (Exception e) {
           System.out.println("Port Hatası!");
      }
      out = new PrintWriter(socket.getOutputStream(), true);
      in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

      System.out.println("Server'a gönderilecek sayısı giriniz:");

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

      while((deger = data.readLine()) != null) {
           out.println(deger);
           System.out.println("Server'dan gelen sonuç = " + in.readLine());
           System.out.println("Server'a gönderilecek saysı giriniz");
      }
      out.close();
      in.close();
      data.close();
      socket.close();
 }

}

Server Kodları: package socketapp;

import java.io.; import java.net.;

public class server {

 public static void main(String[] args) throws IOException {
      String clientGelen;
      ServerSocket serverSocket = null;
      Socket clientSocket = null;

      int sayi;

      try {
           serverSocket = new ServerSocket(3389);
      } catch (Exception e) {
           System.out.println("Port Hatası!");
      }
      System.out.println("SERVER BAŞLANTI İÇİN HAZIR...");
      
      clientSocket = serverSocket.accept();
      
      PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);


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

      while((clientGelen = in.readLine()) != null) {
           System.out.println("Client'dan gelen veri = " + clientGelen);
           sayi = Integer.valueOf(clientGelen);
           out.println(sayi*sayi);
      }
      out.close();
      in.close();
      clientSocket.close();
      serverSocket.close();
 }

}

datacommunication's People

Contributors

izelkayacik avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.