Code example for ServerSocket

Methods: accept, close

0
	} 
 
	@Override 
	public void run() 
	{ 
		try(Socket incoming = socket.accept(); Socket outcoming = new Socket(address, port))
		{ 
			new Writer(incoming.getInputStream(), outcoming.getOutputStream()).start();
			new Writer(outcoming.getInputStream(), incoming.getOutputStream()).start();
		} 
		catch (IOException e)
		{ 
			e.printStackTrace();
		} 
		finally 
		{ 
        	try 
			{ 
				socket.close();
			} 
			catch (IOException e)
			{ 
				e.printStackTrace();
			}