Untitled
unknown
plain_text
a month ago
1.1 kB
2
Indexable
Never
import java.io.*; import java.net.*; import java.lang.*; public class ServerTestPrg { public static void main(String q[]) throws IOException { ServerSocket ss=new ServerSocket(8001); //listening System.out.println("\nServer Running....."); //while(true) // { System.out.println("\nServer wait for Client request...."); Socket cs=ss.accept(); //binding System.out.println("Server established connection...."); DataInputStream in=new DataInputStream(cs.getInputStream()); DataOutputStream out=new DataOutputStream(cs.getOutputStream()); String messageInput=in.readUTF(); int n = Integer.valueOf(messageInput); int sum = 0; int r, temp; temp = n; while (n>0) { r = n%10; sum = (sum * 10) + r; n = n/10; } if(temp == sum) { out.writeUTF("YES"); } else { out.writeUTF("NO"); } // System.out.println("Message From Client: " + num); // BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); // String Message=br.readLine(); // out.writeUTF(Message); //} } }
Leave a Comment