net.anotheria.net.udp.client
Class UDPPacketSender

java.lang.Object
  extended by net.anotheria.net.udp.client.UDPPacketSender

public class UDPPacketSender
extends Object

Utility class which sends packets over udp.

Author:
another

Constructor Summary
UDPPacketSender(int aSourcePort)
          Creates a new UDPPacketSender with the given port as sender port.
UDPPacketSender(int aMinPort, int aMaxPort)
          Creates a new UDPPacketSender with a given port range for the outgoing port.
UDPPacketSender(int aMinPort, int aMaxPort, String aDefaultHost, int aDefaultPort)
          Creates a new UDPPacketSender with outgoing port range, a default target host and port.
UDPPacketSender(int aSourcePort, String aDefaultHost, int aDefaultPort)
          Creates a new UDPPacketSender with a given outgoing port, default target host and port.
 
Method Summary
 void send(byte[] data)
          Sends some data to the default host and port.
 void sendTo(byte[] data, String host, int port)
          Sends some data to the given host and port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UDPPacketSender

public UDPPacketSender(int aSourcePort)
Creates a new UDPPacketSender with the given port as sender port.

Parameters:
aSourcePort - the port to use as outgoing port.

UDPPacketSender

public UDPPacketSender(int aMinPort,
                       int aMaxPort)
Creates a new UDPPacketSender with a given port range for the outgoing port.

Parameters:
aMinPort - the min port in the outgoing port range
aMaxPort - the max port in the outgoing port range

UDPPacketSender

public UDPPacketSender(int aSourcePort,
                       String aDefaultHost,
                       int aDefaultPort)
Creates a new UDPPacketSender with a given outgoing port, default target host and port.

Parameters:
aSourcePort - the port to use as outgoing port.
aDefaultHost - the default target host.
aDefaultPort - the default target port.

UDPPacketSender

public UDPPacketSender(int aMinPort,
                       int aMaxPort,
                       String aDefaultHost,
                       int aDefaultPort)
Creates a new UDPPacketSender with outgoing port range, a default target host and port.

Parameters:
aMinPort - the min port in the outgoing port range
aMaxPort - the max port in the outgoing port range
aDefaultHost - the default target host.
aDefaultPort - the default target port.
Method Detail

send

public void send(byte[] data)
Sends some data to the default host and port.

Parameters:
data - the data to send.

sendTo

public void sendTo(byte[] data,
                   String host,
                   int port)
Sends some data to the given host and port.

Parameters:
data - the data to send.
host - the host to send the data to.
port - the port to send the data to.


Copyright © 2010-2013 anotheria.net. All Rights Reserved.