Class UDPTransport
java.lang.Object
com.epam.common.transport.client.udp.UDPTransport
- All Implemented Interfaces:
ClientTransport
,Transport
UDP transport implementation.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates UDP transport.UDPTransport
(String multicastAddress, int port) Creates UDP transport. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the transport.Getter for address value.Getter for address value.int
Getter for local port value.int
getPort()
Getter for port value.boolean
boolean
isOpen()
Returnstrue
if, transport is open.void
open()
Method opens the transport.int
read
(byte[] buffer) Transport dependent read method.int
read
(byte[] buffer, int offset, int length) Transport dependent read method.int
read
(ByteBuffer buffer) int
read
(ByteBuffer buffer, int offset, int length) void
setAddress
(String multicastAddress) Setter for multicat address.void
setBufferSize
(int bufferSize) void
setNetworkInterfaceName
(String networkInterface) Setter for network interface.void
setPort
(int port) Setter for port.void
setSocketFactory
(SocketFactory socketFactory) void
void
write
(byte[] message) Transport dependent write method.int
write
(byte[] message, int offset, int length) Transport dependent write method.int
write
(ByteBuffer buffer) int
write
(ByteBuffer buffer, int offset, int length) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.epam.common.transport.Transport
getSSLCertificates, getSSLCipherSuite, getSSLProtocol
-
Constructor Details
-
UDPTransport
public UDPTransport()Creates UDP transport. -
UDPTransport
Creates UDP transport.- Parameters:
multicastAddress
- the multicast addressport
- the transport port
-
-
Method Details
-
setSocketFactory
- Specified by:
setSocketFactory
in interfaceClientTransport
-
isBlockingSocket
public boolean isBlockingSocket()- Specified by:
isBlockingSocket
in interfaceTransport
-
setNetworkInterfaceName
Setter for network interface.- Parameters:
networkInterface
-
-
setBufferSize
public void setBufferSize(int bufferSize) -
setAddress
Setter for multicat address.- Specified by:
setAddress
in interfaceClientTransport
- Parameters:
multicastAddress
- the multicat address
-
setPort
public void setPort(int port) Setter for port.- Specified by:
setPort
in interfaceClientTransport
- Parameters:
port
- the transport port
-
open
Method opens the transport. The implementation create a multicast socket and bind it to a specific port, and then joins created socket to multicast group.- Specified by:
open
in interfaceTransport
- Throws:
IOException
- - if an I/O error occurs.
-
close
Closes the transport.Leave a multicast group and close socket.
- Specified by:
close
in interfaceTransport
- Throws:
IOException
- - if an I/O error occurs.
-
isOpen
public boolean isOpen()Description copied from interface:Transport
Returnstrue
if, transport is open. -
write
Description copied from interface:Transport
Transport dependent write method.- Specified by:
write
in interfaceTransport
- Parameters:
message
- actual message- Throws:
IOException
- if unable to write- See Also:
-
write
Description copied from interface:Transport
Transport dependent write method.- Specified by:
write
in interfaceTransport
- Parameters:
message
- actual messageoffset
- the offset in bufferlength
- the num of bytes to write- Throws:
IOException
- if unable to write
-
read
Description copied from interface:Transport
Transport dependent read method.- Specified by:
read
in interfaceTransport
- Parameters:
buffer
- holder for read bytes- Returns:
- number of byte actually read
- Throws:
IOException
- if unable to read- See Also:
-
read
Description copied from interface:Transport
Transport dependent read method.- Specified by:
read
in interfaceTransport
- Parameters:
buffer
- holder for read bytesoffset
- in bufferlength
- maximum bytes to be read- Returns:
- number of byte actually read
- Throws:
IOException
- if unable to read- See Also:
-
getAddress
Description copied from interface:Transport
Getter for address value.- Specified by:
getAddress
in interfaceTransport
- See Also:
-
getInetAddress
Description copied from interface:Transport
Getter for address value.- Specified by:
getInetAddress
in interfaceTransport
-
getPort
public int getPort()Description copied from interface:Transport
Getter for port value. -
getLocalPort
public int getLocalPort()Description copied from interface:Transport
Getter for local port value.- Specified by:
getLocalPort
in interfaceTransport
-
write
- Specified by:
write
in interfaceClientTransport
- Specified by:
write
in interfaceTransport
- Throws:
IOException
-
write
- Specified by:
write
in interfaceClientTransport
- Specified by:
write
in interfaceTransport
- Throws:
IOException
-
read
- Specified by:
read
in interfaceClientTransport
- Specified by:
read
in interfaceTransport
- Throws:
IOException
-
read
- Specified by:
read
in interfaceClientTransport
- Specified by:
read
in interfaceTransport
- Throws:
IOException
-
waitUntilReadyToWrite
- Specified by:
waitUntilReadyToWrite
in interfaceTransport
- Throws:
IOException
-