public static void writeObject(final InetAddress inetAddress, final int port,
		final Object objectToSend) throws IOException
	{
		Socket socketToClient = null;
		ObjectOutputStream oos = null;

		try
		{
			socketToClient = new Socket(inetAddress, port);
			oos = new ObjectOutputStream(
				new BufferedOutputStream(socketToClient.getOutputStream()));
			oos.writeObject(objectToSend);
			oos.close();
			socketToClient.close();
		}
		catch (final IOException e)
		{
			LOGGER.error("IOException occured by trying to write the object.", e);
			throw e;
		}
		finally
		{
			try
			{
				if (oos != null)
				{
					oos.close();
				}
				close(socketToClient);
			}
			catch (final IOException e)
			{
				LOGGER.error("IOException occured by trying to close the socket.", e);
				throw e;
			}
		}
	}
public static void writeObject ( final InetAddress inetAddress , final int port , final Object objectToSend ) throws IOException { Socket socketToClient = null ; ObjectOutputStream oos = null ; try { socketToClient = new Socket ( inetAddress , port ) ; oos = new ObjectOutputStream ( new BufferedOutputStream ( socketToClient . getOutputStream ( ) ) ) ; oos . writeObject ( objectToSend ) ; oos . close ( ) ; socketToClient . close ( ) ; } catch ( final IOException e ) { LOGGER . error ( "IOException occured by trying to write the object." , e ) ; throw e ; } finally { try { if ( oos != null ) { oos . close ( ) ; } close ( socketToClient ) ; } catch ( final IOException e ) { LOGGER . error ( "IOException occured by trying to close the socket." , e ) ; throw e ; } } }
Writes the given Object to the given InetAddress who listen to the given port.

@param inetAddress
the inet address
@param port
The port who listen the receiver.
@param objectToSend
The Object to send.
@throws IOException
Signals that an I/O exception has occurred.