part-02-materi-kedua.pdf

Upload: harjantoutomo

Post on 08-Jul-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 part-02-materi-kedua.pdf

    1/8

    NETWORKPROGRAMMING

    Part II [DNS] [TCP] [UDP]

  • 8/19/2019 part-02-materi-kedua.pdf

    2/8

    C# DNS Class

    Method-method yang penting: .GetHostAddresses (string)

    Returns the Internet Protocol (IP) addresses for the specified host.

    Contoh:public static void DoGetHostAddresses(string hostname) {

    IPAddress[] ips;ips = Dns.GetHostAddresses(hostname);

    Console.WriteLine("GetHostAddresses({0}) returns:",hostname);

    foreach (IPAddress ip in ips) {Console.WriteLine(" {0}", ip);

    }}

  • 8/19/2019 part-02-materi-kedua.pdf

    3/8

    C# DNS Class

    Method-method yang penting: . GetHostEntry (string)

    Resolves an IP address to an IPHostEntry instance.Contoh:public static void DoGetHostEntry(string hostname){

    IPHostEntry host;host = Dns.GetHostEntry(hostname);Console.WriteLine("GetHostEntry({0}) returns:", hostname);foreach (IPAddress ip in host.AddressList)

    { Console.WriteLine(" {0}", ip);}

    }

  • 8/19/2019 part-02-materi-kedua.pdf

    4/8

    C# DNS Class

    Method-method yang penting: . GetHostName ()

    Gets the host name of the local computer.Contoh:public void DisplayLocalHostName(){

    try { String hostName = Dns.GetHostName();Console.WriteLine("Computer name :" + hostName);

    }catch(Exception e)

    { Console.WriteLine("Source : " + e.Source);Console.WriteLine("Message : " + e.Message);}

    }

  • 8/19/2019 part-02-materi-kedua.pdf

    5/8

    C# DNS Class

    Depricated / Obsolete MethodsBeberapa method ini sudah dikategorikan obsolete oleh Microsoft sejak .NET

    Framework 2.0. Maksudnya adalah, method-method ini sudah tidak layakpakai, dan sebaiknya gunakan method-method yang baru. Dalam hal inipenggantinya adalah GetHostEntryGetHostByAddress(IPAddress)

    GetHostByAddress(String)

    GetHostByName

    Resolve

  • 8/19/2019 part-02-materi-kedua.pdf

    6/8

    TCP - Connection-Oriented Sockets

    TCP Server. Langkah-langkahnya:Create a socketBind the socket to a local IPEndPointPlace the socket in listen modeAccept an incoming connection on the socket

    Kode program, ikut di ebook Chapter 5. A SimpleTCP Server

  • 8/19/2019 part-02-materi-kedua.pdf

    7/8

    Tugas

    Chapter 5: Connection-Oriented SocketPart: When TCP Goes Bad (Pelajari bagian ini untukmengerjakan tugas berikut).

    Jelaskan dengan kata-katamu sendiri problema apasaja yang sering ditemui ketika membuat programclient-server oleh programmer baru.Jelaskan pula solusinya.Tambahkan potongan kode program seperlunya saja.

  • 8/19/2019 part-02-materi-kedua.pdf

    8/8

    Ketentuan Pengumpulan Tugas

    Dikumpulkan minggu depan.Ukuran kertas A4 80gram, margin atas 4 kiri 4 kanan 3bawah 3.

    Maksimal 2 halaman.