Tag Archives: localhost

Membuat http Server Sederhana dengan Java

pic2_resize.JPG

Tugas Praktikum Pemrograman Jaringan dan Piranti Bergerak yang kedua adalah membuat sebuah http server sederhana di localhost. Dengan memanfaatkan fungsi SocketServer, maka dapat dibuat sebuah server yang akan menunggu “panggilan” pada port 80 (HTTP). Dan akan mengirimkan kode html ketika “dipanggil”.

SocketServer bekerja dalam sebuah looping yang terus menerus untuk menunggu adanya koneksi ke port 80 pada localhost. Ada 4 constructor pada SocketServer antara lain:

  1. public ServerSocket(int port) throws BindException, IOException
  2. public ServerSocket(int port, int queueLength) throws BindException, IOException
  3. public ServerSocket(int port, int queueLength, InetAddress bindAddress) throws IOException
  4. public ServerSocket( ) throws IOException // Java 1.4

Continue reading