@Override
	public OutputStream getOutputStream() throws IOException
	{
		if(toNetStream == null) {
			toNetStream = new OutputStream() {
				@Override
				public void write(int value) throws IOException
				{
					try {
						BaseConnectionEndPoint.this.write(new byte[] { (byte)value });
					}
					catch(NetworkException exc) {
						throw new IOException(exc);
					}
				}
				
				public synchronized void write(byte b[], int off, int len) throws IOException
				{
					if(b != null) {
						try {
							// Copy array since some apps will reuse b in order
							// to send the next data chunk! That copy can only be
							// avoided, if the calls behind "write" really do a
							// deep copy of the packet. However, the payload will
							// only be copied if the packet is send through a real
							// lower layer. In pure simulation scenarios that never
							// happens.
							byte[] copyB = new byte[len];
							System.arraycopy(b, off, copyB, 0, len);
							
							BaseConnectionEndPoint.this.write(copyB);
						}
						catch(NetworkException exc) {
							throw new IOException(exc);
						}
					}
				}
				
				@Override
				public void flush() throws IOException
				{
					// nothing to do
				}

			};
		}

		return toNetStream;
	}