Java Reading from a socket

Socket socket = new Socket();
		try {
			socket.connect(new InetSocketAddress("46.4.102.53", 7777));
			System.out.println("connected!");
			BufferedReader in = new BufferedReader(new InputStreamReader(
                    socket.getInputStream()));
			 String inputLine;
		        while ((inputLine = in.readLine()) != null) 
		            System.out.println(inputLine);
		        in.close();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Leave a Reply

Your email address will not be published. Required fields are marked *