Code example for Socket

Methods: getInputStreamgetLocalAddressgetLocalPortgetOutputStream

0
	} 
 
	public Echo(String host, int port) throws IOException, UnknownHostException {
 
		System.out.println("Connecting...");
		ss = new Socket(host, port);
		out = ss.getOutputStream();
		in = ss.getInputStream();
		System.out.println("TO: " + host + ":" + port);
		System.out.println("LocalAddress: "
				+ ss.getLocalAddress().getHostAddress() + ":"
				+ ss.getLocalPort());
 
	} 
 
	public void send(String s) throws IOException {
		// System.out.println("Sending:"+s); 
		out.write(s.getBytes());
	} 
 
Stop searching for code, let great code find you!  Add Codota to your java IDE