Class BroadCastService
java.lang.Object
de.ipk_gatersleben.ag_nw.graffiti.services.network.BroadCastService
- All Implemented Interfaces:
HelperClass
public class BroadCastService extends Object implements HelperClass
Creates a broadcast-service which allows sending and receiving of broadcast
messages.
- Author:
- Christian Klukas (c) 2004 IPK-Gatersleben
-
Constructor Summary
Constructors Constructor Description BroadCastService(int udpPortStart, int udpPortEnd, int maxMessageLen)
Creates a broadcast-service which allows sending and receiving of broadcast messages. -
Method Summary
Modifier and Type Method Description int
getBindPort()
int
getEndPort()
int
getInCount()
int
getOtherInCount()
int
getOutCount()
int
getStartPort()
void
increaseInCount()
UDPreceiveStructure
receiveBroadcast(int timeout)
Receives and returns the data contained in a broadcast message.void
sendBroadcast(byte[] msg)
Sends a broadcast to all of the nodes the ip should be the ip for the network
-
Constructor Details
-
BroadCastService
public BroadCastService(int udpPortStart, int udpPortEnd, int maxMessageLen)Creates a broadcast-service which allows sending and receiving of broadcast messages. A default target IP of 255.255.255.255 is used.- Parameters:
udpPort
- The UDP Port where the data is received and send.maxMessageLen
- The maximum length of bytes that is allowed to send and receive by this service.
-
-
Method Details
-
sendBroadcast
Sends a broadcast to all of the nodes the ip should be the ip for the network- Parameters:
msg
- the message to be sendip
- the ip address to use for the broadcast packet- Throws:
IOException
- if cannot send the packetIllegalArgumentException
-
receiveBroadcast
Receives and returns the data contained in a broadcast message. Set timeout <= 0 if you wish to have no timeout- Throws:
IOException
-
increaseInCount
public void increaseInCount() -
getInCount
public int getInCount() -
getOutCount
public int getOutCount() -
getOtherInCount
public int getOtherInCount() -
getStartPort
public int getStartPort() -
getEndPort
public int getEndPort() -
getBindPort
public int getBindPort()
-