Code example for Socket

Methods: closegetInputStreamgetOutputStream

0
		} catch (IOException e) {
		} 
	} 
	private void serverStarten() throws IOException{ 
		try{ 
			this.client = new Socket("localhost",this.port);
			OutputStream output = (OutputStream) client.getOutputStream();
			InputStream input = client.getInputStream();
 
			byte[] bytes = this.nachricht.getBytes();
 
			output.write(bytes);
			output.flush();
			int zahl = input.available();
			if (zahl > 0){
				byte[] lesen = new byte[zahl];
				input.read(lesen);
			} 
		 
			client.close();
			input.close();
			output.close();
		}catch(NullPointerException ex){
			ex.printStackTrace();
		}catch (IOException e) {
Stop searching for code, let great code find you!  Add Codota to your java IDE