Programming Blog

This blog is about technical and programming questions and there solutions. I also cover programs that were asked in various interviews, it will help you to crack the coding round of various interviews

Thursday, 31 August 2017

java program to print the current date and time of client

import java.io.*;
import java.net.*;
public class ClientDate {
public static void main(String args[])throws Exception
{
Socket S1 = new Socket("Local ip Address", Port);
PrintWriter out= new PrintWriter(S1.getOutputStream(),true);
BufferedReader b=new BufferedReader(new InputStreamReader(S1.getInputStream()));
String a=b.readLine();
System.out.println("Date and Time "+ a);
S1.close();
    out.close();
}}



/* ip address =127.0.0.1 and port is any between 0 - 65536*/

No comments:

Post a Comment