Presentasi sedang didownload. Silahkan tunggu

Presentasi sedang didownload. Silahkan tunggu

Pemrograman Client Server

Presentasi serupa


Presentasi berjudul: "Pemrograman Client Server"— Transcript presentasi:

1 Pemrograman Client Server
Pustaka TCP/IP Socket in Java Practical Guide for Programmers Oleh : Kenneth L. Calvert (University of Kentucky), Michael Donahoo (Baylor University) An Introduction to Network Programming With Java Oleh : Jan Graba Sheffield Hallam Universisty, UK Pemrograman Client/Server dengan Java 2 Oleh : Budi Susanto Elex Media

2 Client, Server, peer to peer
Bagian yang meminta layanan pada server Server Bagian yang melayani permintaan client Peer to peer Diantara host mempunyai kedudukan yang sama Contoh : sharing, file, direktori

3 Client - server Sebuah proses pada client melakukan permintaan ke Server Aplikasi server menerima permintaan dari client request Server Client response

4 Protocol TCP/IP Protocol Standar Internet Application Presentation
5 Presentation 4 Application Session 3 Transport Transport 2 Network Internet 1 Data-Link Data-Link Physical Physical Tcp/ip osi

5 Application Layer File Transfer - TFTP* - FTP* - NFS E-Mail - SMTP
Remote Login - Telnet* - rlogin* Network Management - SNMP* Name Management - DNS* Application Transport Internet Data-Link Physical

6 Transport Layer Connection-Oriented Connectionless
Transmission Control Protocol (TCP) User Datagram Protocol (UDP) Connection-Oriented Connectionless Application Transport Internet Data-Link Physical

7 Port Numbers F T P T E L N E T S M T P D N S T F T P S N M P R I P
Application Layer 21 23 25 53 69 161 520 TCP UDP

8 Internet Layer Internet Protocol (IP) Internet Control Message
Protocol (ICMP) Address Resolution Protocol (ARP) Reverse Address Resolution Protocol (RARP) Application Transport Internet Data-Link Physical

9 Port dan Socket Socket Sebuah Abstraksi perangkat lunak yang digunakan sebagai “terminal” dari suatu hubungan dua mesin, proses yang saling koneksi Setiap mesin yang berkomunikasi harus terpasang socket Port Nomor untuk identifikasi proses Menggunajan nilai 16 bit Baberapa layanan port, mengunakan nilai baku

10 Contoh service port

11 Java Socket Terdapat pada paket java.net
Berisi kelas-kelas dan interface Menyediakan API protokol UDP, TCP Terdiri misal java.net.ServerSocket java.net.Socket java.net.DatagramSocket java.net.InetAddress

12 Class Socket Kelas ini klien mengimplementasikan soket
(juga disebut hanya "socket"). Sebuah socket adalah sebuah endpoint untuk komunikasi antara dua mesin. Constructor Socket() Menciptakan soket tidak berhubungan, dengan sistem-default jenis SocketImpl .

13 Socket java Socket(InetAddress address, int port)
Menciptakan stream soket dan menghubungkan ke nomor port tertentu pada alamat IP yang ditentukan. Socket(InetAddress host, int port, boolean stream) Deprecated. Gunakan UDP DatagramSocket bukan untuk transportasi. Socket(InetAddress address, int port, InetAddress localAddr, int localPort) Menciptakan soket dan menghubungkan ke alamat remote tertentu pada remote port yang disyaratkan.

14 Construktor Socket(SocketImpl impl)
Socket memciptakan nonkoneksi dengan user-SocketImpl ditentukan.. void bind(SocketAddress bindpoint) Mengikat socket ke alamat lokal.           .   void close() Menututup socket   void connect(SocketAddress endpoint) Soket ini menghubungkan ke server. void connect(SocketAddress endpoint, int timeout) Soket ini menghubungkan ke server dengan nilai timeout tertentu.

15 Methode getInetAddress
public InetAddress getInetAddress() Mengembalikan alamat yang soket tersambung. Pengembalian: alamat IP remote yang terhubung socket ini, atau null jika soket tidak tersambung. getLocalAddress public InetAddress getLocalAddress() Mendapatkan alamat lokal yang soket diikat. Pengembalian: alamat lokal yang soket diikat atau InetAddress.anyLocalAddress () jika tidak terikat soket tidak terikat.

16 Methode getPort public int getPort () Mengembalikan port remote yang soket ini tersambung.  Pengembalian:  nomor port remote yang terhubung socket ini, atau 0 jika soket tidak terhubung. getLocalPort public int getLocalPort ()   Mengembalikan port lokal yang soket ini terikat. Pengembalian:         nomor port setempat yang soket ini diikat atau -1 jika socket tidak terikat belum.

17 Methode getRemoteSocketAddress SocketAddress publik getRemoteSocketAddress () Mengembalikan alamat titik akhir soket ini terhubung ke, atau null jika tidak tersambung. Pengembalian: SocketAddress reprensentasi sebuah titik akhir jauh soket ini, atau null jika tidak terhubung . getLocalSocketAddress SocketAddress publik getLocalSocketAddress ()   Mengembalikan alamat endpoint soket ini terikat pada, atau null jika tidak terikat. Pengembalian: SocketAddress mewakili sebuah titik akhir lokal soket ini, atau null jika tidak terikat be.     


Download ppt "Pemrograman Client Server"

Presentasi serupa


Iklan oleh Google