IP*Works! V9

ipworks
Class Mcast

java.lang.Object
  extended by ipworks.Mcast

public class Mcast
extends java.lang.Object

The MCast bean is used to multicast UDP datagrams to multicast capable hosts in multicast capable subnets. It can act both as a client and a server and communicate with any number of hosts simultaneously, as well as generate and receive broadcast packets.

The MCast bean is very similar to UDPPort, except for some additional properties that provide support for multicast datagrams. To send datagrams to a multicast group, simply assign the address of the group to RemoteHost . To receive datagrams from one or more groups, assign the group addresses to MulticastGroup one by one (after the bean is activated. TimeToLive allows to specify how many subnets a packet should be allowed to receive. ReceiveInterface and SendInterface allow you to select the network interface for multicast operations.

The bean is activated/deactivated through the Active property. This property enables or disables sends or receives. The data can be sent in the same way as UDPPort, by calling the Send method with a Text parameter or via the DataToSend property. The destination is specified using the RemoteHost and RemotePort properties. Inbound data is received through the DataIn event.


Constructor Summary
Mcast()
          Creates an instance of Mcast Bean.
Mcast(java.lang.String runtimeLicense)
          Creates an instance of Mcast Bean with specified run-time license.
 
Method Summary
 void addMcastEventListener(McastEventListener l)
           
 java.lang.String config(java.lang.String configurationString)
          Sets or retrieves a configuration setting.
 void doEvents()
          Processes events from the internal message queue.
 java.lang.String getLocalHost()
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 int getLocalPort()
          The UDP port in the local host where MCast binds.
 java.lang.String getMulticastGroup()
          Multicast group to join or leave.
 java.lang.String getReceiveInterface()
          The interface with which to receive multicast packets.
 java.lang.String getRemoteHost()
          The address of the remote host (multicast group).
 int getRemotePort()
          The UDP port in the remote host.
 java.lang.String getSendInterface()
          The interface from which multicast packets are sent.
 int getTimeToLive()
          The maximum number of subnets that a multicast datagram can traverse.
 boolean isAcceptData()
          Enables or disables data reception (the DataIn event).
 boolean isActive()
          Enables or disables sending and receiving data.
 boolean isLoopback()
          Enables or disables loopback of data sent to the multicast group.
 void removeMcastEventListener(McastEventListener l)
           
 void send(byte[] text)
          Sends data to the remote host.
 void setAcceptData(boolean acceptData)
          Enables or disables data reception (the DataIn event).
 void setActive(boolean active)
          Enables or disables sending and receiving data.
 void setDataToSend(byte[] dataToSend)
          A string of data to be sent to the remote host.
 void setLocalHost(java.lang.String localHost)
          The name of the local host or user-assigned IP interface through which connections are initiated or accepted.
 void setLocalPort(int localPort)
          The UDP port in the local host where MCast binds.
 void setLoopback(boolean loopback)
          Enables or disables loopback of data sent to the multicast group.
 void setMulticastGroup(java.lang.String multicastGroup)
          Multicast group to join or leave.
 void setReceiveInterface(java.lang.String receiveInterface)
          The interface with which to receive multicast packets.
 void setRemoteHost(java.lang.String remoteHost)
          The address of the remote host (multicast group).
 void setRemotePort(int remotePort)
          The UDP port in the remote host.
 void setSendInterface(java.lang.String sendInterface)
          The interface from which multicast packets are sent.
 void setTimeToLive(int timeToLive)
          The maximum number of subnets that a multicast datagram can traverse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mcast

public Mcast()
Creates an instance of Mcast Bean.


Mcast

public Mcast(java.lang.String runtimeLicense)
Creates an instance of Mcast Bean with specified run-time license.

Method Detail

isAcceptData

public boolean isAcceptData()
Enables or disables data reception (the DataIn event).

This property enables or disables data reception (the DataIn event). Setting this property to False, temporarily disables data reception (and the DataIn event). Setting this property to True, re-enables data reception.


setAcceptData

public void setAcceptData(boolean acceptData)
                   throws IPWorksException
Enables or disables data reception (the DataIn event).

This property enables or disables data reception (the DataIn event). Setting this property to False, temporarily disables data reception (and the DataIn event). Setting this property to True, re-enables data reception.

Throws:
IPWorksException

isActive

public boolean isActive()
Enables or disables sending and receiving data.

This property enables or disables sending and receiving data. Setting this property to True makes MCast create a communication endpoint (socket) which can be used for sending and receiving UDP datagrams. Setting this property to False destroys the socket and disables data communications.


setActive

public void setActive(boolean active)
               throws IPWorksException
Enables or disables sending and receiving data.

This property enables or disables sending and receiving data. Setting this property to True makes MCast create a communication endpoint (socket) which can be used for sending and receiving UDP datagrams. Setting this property to False destroys the socket and disables data communications.

Throws:
IPWorksException

setDataToSend

public void setDataToSend(byte[] dataToSend)
                   throws IPWorksException
A string of data to be sent to the remote host. Write-only property.

This write-only property contains a string of data to be sent to the remote host. Assigning a string to this property makes the bean send the string to the remote host. The Send method provides similar functionality.

The TCP/IP subsystem attempts to send the string assigned to this property as a complete message. If socket buffers are full, or the message cannot be delivered for any reason, an error is fired, and no portion of the message is sent. This is different from TCP where portions of the messages can be sent. The bean sends either a complete message or nothing at all.

If you are sending data to the remote host faster than it can process it, or faster than the network's bandwidth allows, the outgoing queue might fill up. When this happens, this property fails with exception 10035: "[10035] Operation would block" (WSAEWOULDBLOCK). You can check this error, and then try to send the data again. .

Throws:
IPWorksException

getLocalHost

public java.lang.String getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted.

The LocalHost property contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.

In multi-homed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.

If the bean is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multi-homed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.


setLocalHost

public void setLocalHost(java.lang.String localHost)
                  throws IPWorksException
The name of the local host or user-assigned IP interface through which connections are initiated or accepted.

The LocalHost property contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.

In multi-homed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.

If the bean is connected, the LocalHost property shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multi-homed hosts (machines with more than one IP interface).

NOTE: LocalHost is not persistent. You must always set it in code, and never in the property window.

Throws:
IPWorksException

getLocalPort

public int getLocalPort()
The UDP port in the local host where MCast binds.

This property must be set before MCast is activated ( Active is set to True). It instructs the bean to bind to a specific port (or communication endpoint) in the local machine.

Setting it to 0 (default) enables the system to choose a port at random. The chosen port will be shown by this property after the connection is established.

This property cannot be changed once the bean is Active . Any attempt to set this property when the bean is Active will generate an error.

This property is useful when trying to send data to services that require a trusted port in the client side.


setLocalPort

public void setLocalPort(int localPort)
                  throws IPWorksException
The UDP port in the local host where MCast binds.

This property must be set before MCast is activated ( Active is set to True). It instructs the bean to bind to a specific port (or communication endpoint) in the local machine.

Setting it to 0 (default) enables the system to choose a port at random. The chosen port will be shown by this property after the connection is established.

This property cannot be changed once the bean is Active . Any attempt to set this property when the bean is Active will generate an error.

This property is useful when trying to send data to services that require a trusted port in the client side.

Throws:
IPWorksException

isLoopback

public boolean isLoopback()
Enables or disables loopback of data sent to the multicast group.

This property enables or disables loopback of data sent to the multicast group. Setting this property to False disables loopback of data sent through the bean (normally loopback is enabled). This property is directly related to the IP_MULTICAST_LOOP socket option.


setLoopback

public void setLoopback(boolean loopback)
                 throws IPWorksException
Enables or disables loopback of data sent to the multicast group.

This property enables or disables loopback of data sent to the multicast group. Setting this property to False disables loopback of data sent through the bean (normally loopback is enabled). This property is directly related to the IP_MULTICAST_LOOP socket option.

Throws:
IPWorksException

getMulticastGroup

public java.lang.String getMulticastGroup()
Multicast group to join or leave.

This property contains the multicast group to join or leave. Multicast groups are joined by assigning values to this property after the bean is activated. More than one group may be joined at the same time. To define which interface to use, the ReceiveInterface property is used.

Determining whether a group is left or joined is done by setting the first letter of MulticastGroup is "-" or "+". The default operation is join.

To remove the bean from a multicast group once it is joined, simply assign this groupname (address) to MulticastGroup prefixed by a minus sign "-".

Example (Joining/Leaving Groups)

 MCastControl.Active = true
 MCastControl.MulticastGroup = "+231.31.31.31"
 MCastControl.MulticastGroup = "+232.32.32.32"
 
 MCastControl.MulticastGroup = "-232.32.32.32"
 MCastControl.MulticastGroup = "-231.31.31.31" 


setMulticastGroup

public void setMulticastGroup(java.lang.String multicastGroup)
                       throws IPWorksException
Multicast group to join or leave.

This property contains the multicast group to join or leave. Multicast groups are joined by assigning values to this property after the bean is activated. More than one group may be joined at the same time. To define which interface to use, the ReceiveInterface property is used.

Determining whether a group is left or joined is done by setting the first letter of MulticastGroup is "-" or "+". The default operation is join.

To remove the bean from a multicast group once it is joined, simply assign this groupname (address) to MulticastGroup prefixed by a minus sign "-".

Example (Joining/Leaving Groups)

 MCastControl.Active = true
 MCastControl.MulticastGroup = "+231.31.31.31"
 MCastControl.MulticastGroup = "+232.32.32.32"
 
 MCastControl.MulticastGroup = "-232.32.32.32"
 MCastControl.MulticastGroup = "-231.31.31.31" 

Throws:
IPWorksException

getReceiveInterface

public java.lang.String getReceiveInterface()
The interface with which to receive multicast packets. If empty, default is used.

This property is useful when there is more than one network interface, and the one used for receiving multicast datagrams is not the default. If you wish to set an interface other than the system default, provide the IP address of the interface to be set.

This property is used together with the MulticastGroup property to join one or more multicast groups. The joining is done after the bean is activated by assigning proper values to MulticastGroup .


setReceiveInterface

public void setReceiveInterface(java.lang.String receiveInterface)
                         throws IPWorksException
The interface with which to receive multicast packets. If empty, default is used.

This property is useful when there is more than one network interface, and the one used for receiving multicast datagrams is not the default. If you wish to set an interface other than the system default, provide the IP address of the interface to be set.

This property is used together with the MulticastGroup property to join one or more multicast groups. The joining is done after the bean is activated by assigning proper values to MulticastGroup .

Throws:
IPWorksException

getRemoteHost

public java.lang.String getRemoteHost()
The address of the remote host (multicast group).

This property contains the address of the remote host (multicast group). To send a multicast datagram, specify a RemoteHost value in the range of 224.0.0.0 to 239.255.255.255. These addresses are reserved as multicast addresses by IP.


setRemoteHost

public void setRemoteHost(java.lang.String remoteHost)
                   throws IPWorksException
The address of the remote host (multicast group).

This property contains the address of the remote host (multicast group). To send a multicast datagram, specify a RemoteHost value in the range of 224.0.0.0 to 239.255.255.255. These addresses are reserved as multicast addresses by IP.

Throws:
IPWorksException

getRemotePort

public int getRemotePort()
The UDP port in the remote host.

This property contains the UDP port on the RemoteHost to send UDP datagrams to.

A valid port number (a value between 1 and 65535) is required.


setRemotePort

public void setRemotePort(int remotePort)
                   throws IPWorksException
The UDP port in the remote host.

This property contains the UDP port on the RemoteHost to send UDP datagrams to.

A valid port number (a value between 1 and 65535) is required.

Throws:
IPWorksException

getSendInterface

public java.lang.String getSendInterface()
The interface from which multicast packets are sent. If empty, default is used.

This property is useful when there is more than one network interface, and the one used for sending multicast datagrams is not the default. If you wish to set an interface other than the system default, provide the IP address of the interface to be set.


setSendInterface

public void setSendInterface(java.lang.String sendInterface)
                      throws IPWorksException
The interface from which multicast packets are sent. If empty, default is used.

This property is useful when there is more than one network interface, and the one used for sending multicast datagrams is not the default. If you wish to set an interface other than the system default, provide the IP address of the interface to be set.

Throws:
IPWorksException

getTimeToLive

public int getTimeToLive()
The maximum number of subnets that a multicast datagram can traverse.

This property contains the maximum number of subnets that a multicast datagram can traverse. The default value for this property is 7. This is an arbitrary value. You need to specify a value suitable for your application.

Multicast datagrams with this property set to 0 are not transmitted on any subnetwork. Multicast datagrams with this property set to 1 are delivered only on the local network. Multicast datagrams with this property set to greater than 1 may be delivered to more than one subnetwork if there are one or more multicast routers attached to the first-hop subnetwork.

A multicast router does not forward multicast datagrams with destination addresses between 224.0.0.0 and 224.0.0.255, inclusive, regardless of their TimeToLive . This particular range of addresses is reserved for the use of routing protocols and other low-level topology discovery or maintenance protocols, such as gateway discovery and group membership reporting.


setTimeToLive

public void setTimeToLive(int timeToLive)
                   throws IPWorksException
The maximum number of subnets that a multicast datagram can traverse.

This property contains the maximum number of subnets that a multicast datagram can traverse. The default value for this property is 7. This is an arbitrary value. You need to specify a value suitable for your application.

Multicast datagrams with this property set to 0 are not transmitted on any subnetwork. Multicast datagrams with this property set to 1 are delivered only on the local network. Multicast datagrams with this property set to greater than 1 may be delivered to more than one subnetwork if there are one or more multicast routers attached to the first-hop subnetwork.

A multicast router does not forward multicast datagrams with destination addresses between 224.0.0.0 and 224.0.0.255, inclusive, regardless of their TimeToLive . This particular range of addresses is reserved for the use of routing protocols and other low-level topology discovery or maintenance protocols, such as gateway discovery and group membership reporting.

Throws:
IPWorksException

config

public java.lang.String config(java.lang.String configurationString)
                        throws IPWorksException
Sets or retrieves a configuration setting.

Config is a generic method available in every bean. It is used to set and retrieve configuration settings for the bean.

Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the Config method.

To set a configuration setting named PROPERTY , you must call Config("PROPERTY=VALUE") , where VALUE is the value of the setting expressed as a string. For boolean values, use the strings "True", "False", "0", "1", "Yes", or "No" (case does not matter).

To read (query) the value of a configuration setting, you must call Config("PROPERTY") . The value will be returned as a string.

The bean accepts one or more of the following configuration settings . Configuration settings are similar in functionality to properties, but they are rarely used. In order to avoid "polluting" the property namespace of the bean, access to these internal properties is provided through the Config method.

UDPPort Configuration Settings

CaptureIPPacketInfo
Used to capture the packet information
If this is set to true, the component will capture the IP packet information.The default value for this setting is False.

Note: This setting is only available in Windows.

DestinationAddress
Used to get the destination address from the packet information
If CaptureIPPacketInfo is set to true, then this will be populated with the packet's destination address when a packet is received. This information will be accessible in the DataIn event.Note: This setting is only available in Windows.

LocalHost
The name of the local host through which connections are initiated or accepted
The LocalHost setting contains the name of the local host as obtained by the gethostname() system call, or if the user has assigned an IP address, the value of that address.In multi-homed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the bean initiate connections (or accept in the case of server beans) only through that interface.

If the bean is connected, the LocalHost setting shows the IP address of the interface through which the connection is made in internet dotted format (aaa.bbb.ccc.ddd). In most cases, this is the address of the local host, except for multi-homed hosts (machines with more than one IP interface).

LocalPort
The TCP port in the local host where the bean binds
This must be set before a connection is attempted. It instructs the bean to bind to a specific port (or communication endpoint) in the local machine.Setting this to 0 (default) enables the system to choose a port at random. The chosen port will be shown by LocalPort after the connection is established.

LocalPort cannot be changed once a connection is made. Any attempt to set this when a connection is active will generate an error.

This; setting is useful when trying to connect to services that require a trusted port in the client side. An example is the remote shell (rsh) service in UNIX systems.

MaxPacketSize
The maximum length of the packets that can be received
This setting specifies the maximum size of the datagrams that the bean will accept without truncation.
ShareLocalPort
If set to True, allows more than one instance of the bean to be active on the same local port
This option must be set before the bean is activated through the Active property or it will have no effect.The default value for this setting is False.

UseConnection
Determines whether to use a connected socket
UseConnection specifies whether the bean should use a connected socket or not. The connection is defined as an association in between the local address/port and the remote address/port. As such, this is not a connection in the traditional TCP sense. What it means is only that the bean will send and receive data only to and from the specified destination.The default value for this setting is False.

QOSDSCPValue
Used to specify an arbitrary QOS/DSCP setting (optional)
UseConnection must be True to use this setting. This option allows you to specify an arbitrary DSCP value between 0 and 63. The default is 0. When set to the default value the component will not set a DSCP value.Note: This setting uses the qWAVE API is only available on Windows 7, Windows Server 2008 R2, and later.

QOSTrafficType
Used to specify QOS/DSCP settings (optional)
UseConnection must be True to use this setting. You may specify either the text or integer values: BestEffort (0), Background (1), ExcellentEffort (2), AudioVideo (3), Voice (4), and Control (5).Note: This setting uses the qWAVE API which is only available on Windows Vista and Windows Server 2008 or above.

Note: QOSTrafficType must be set before setting Active to true.

UseIPv6
Whether or not to use IPv6
By default, the component expects an IPv4 address for local and remote host properties, and will create an IPv4 socket. To use IPv6 instead, set this to True.

Socket Configuration Settings

AbsoluteTimeout
Determines whether timeouts are inactivity timeouts or absolute timeouts
If AbsoluteTimeout is set to True, any method which does not complete within Timeout seconds will be aborted. By default, AbsoluteTimeout is False, and the timeout is an inactivity timeout.
FirewallData
Used to send extra data to the firewall
When the firewall is a tunneling proxy, use this property to send custom (additional) headers to the firewall (e.g. headers for custom authentication schemes).
InBufferSize
The size in bytes of the incoming queue of the socket
This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be receiving. Increasing the value of the InBufferSize setting can provide significant improvements in performance in some cases.Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the bean is activated the InBufferSize reverts to its defined size. The same happens if you attempt to make it too large or too small.

OutBufferSize
The size in bytes of the outgoing queue of the socket
This is the size of an internal queue in the TCP/IP stack. You can increase or decrease its size depending on the amount of data that you will be sending. Increasing the value of the OutBufferSize setting can provide significant improvements in performance in some cases.Some TCP/IP implementations do not support variable buffer sizes. If that is the case, when the bean is activated the OutBufferSize reverts to its defined size. The same happens if you attempt to make it too large or too small.

Base Configuration Settings

GUIAvailable
Tells the bean whether or not a message loop is available for processing events
In a GUI-based application, long-running blocking operations may cause the application to stop responding to input until the operation returns. The bean will attempt to discover whether or not the application has a message loop and, if one is discovered, it will process events in that message loop during any such blocking operation.In some non-GUI applications an invalid message loop may be discovered that will result in errant behavior. In these cases, setting GuiAvailable to false will ensure that the bean does not attempt to process external events.

Throws:
IPWorksException

doEvents

public void doEvents()
              throws IPWorksException
Processes events from the internal message queue.

When DoEvents is called, the bean processes any available events. If no events are available, it waits for a preset period of time, and then returns.

Throws:
IPWorksException

send

public void send(byte[] text)
          throws IPWorksException
Sends data to the remote host.

This method sends data to the remote host. Calling this method is equivalent to setting the DataToSend property to Text .

Throws:
IPWorksException

addMcastEventListener

public void addMcastEventListener(McastEventListener l)
                           throws java.util.TooManyListenersException
Throws:
java.util.TooManyListenersException

removeMcastEventListener

public void removeMcastEventListener(McastEventListener l)

IP*Works! V9

Copyright (c) 2013 /n software inc. - All rights reserved.