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 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

      public void sendBroadcast​(byte[] msg) throws IOException, IllegalArgumentException
      Sends a broadcast to all of the nodes the ip should be the ip for the network
      Parameters:
      msg - the message to be send
      ip - the ip address to use for the broadcast packet
      Throws:
      IOException - if cannot send the packet
      IllegalArgumentException
    • receiveBroadcast

      public UDPreceiveStructure receiveBroadcast​(int timeout) throws IOException
      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()