Package de.das.encrypter.comm
Class UdpSender
java.lang.Object
de.das.encrypter.comm.UdpSender
A simple UDP sender expecting a receiver service for a given host address at
the given port, which is able to receive and interpret the data sent.
-
Constructor Summary
ConstructorsConstructorDescriptionUdpSender(int port) Creates a new sender client instance and provides a datagram socket for connection and sending.Creates a new sender client instance and provides a datagram socket for connection and sending.Creates a new sender client instance and provides a datagram socket for connection and sending. -
Method Summary
Modifier and TypeMethodDescriptionvoidcallServer(byte[] data) Tries to send the given byte array as a UDP message to the port of the predefined host.voidcallServer(String host, byte[] data) Tries to send the given byte array as a UDP message to the port of the given host.
-
Constructor Details
-
UdpSender
Creates a new sender client instance and provides a datagram socket for connection and sending.- Parameters:
port- the port number where a service is expected at the host.- Throws:
Exception- if the datagram socket cannot be establisched.
-
UdpSender
Creates a new sender client instance and provides a datagram socket for connection and sending.- Parameters:
host- a predefined host address for later usage.port- the port number where a service is expected at the host.- Throws:
Exception- if the datagram socket cannot be establisched.
-
UdpSender
Creates a new sender client instance and provides a datagram socket for connection and sending.- Parameters:
name- of the sender.host- a predefined host address for later usage.port- the port number where a service is expected at the host.- Throws:
SocketException- if the datagram socket cannot be establisched.
-
-
Method Details
-
callServer
public void callServer(byte[] data) Tries to send the given byte array as a UDP message to the port of the predefined host.- Parameters:
data- the byte array to be sent.
-
callServer
Tries to send the given byte array as a UDP message to the port of the given host.- Parameters:
host- the address of the receiver.data- the byte array to be sent.
-