Posts

Showing posts from January, 2025

cn lab

Image
download   01 programs import java.net. * ; import java.io.*; class Ports { public static void main (String [] args) throws Exception { InetAddress h = InetAddress.getLocalHost(); String host =h. getHostName(); String haddr = h. getHostAddress();  System.out.println("\nHost Name: :"+ host);  System.out.println("In Host Address:: "+haddr); for (int i=0; i < 1024; i++) { Socket s=null; try  { s = new Socket ((host), i); System.out.println(" port "+ i + "Active"); } catch (SocketException se) { } catch(Exception e) { System.out.println(" Error...."); } } } } Output:- 02 -program 2 a) import java.io.*; import java.net. *; import java.lang. * ; class chats extends Thread { public static void main (String args []) { try { ServerSocket ss = new ServerSocket (111);  System.out.println ("server ready ");  Socket s = ss.accept (...