|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectipworks.Mx
public class Mx
The MX bean enables querying of mail exchange (MX) records from a Domain Name Server (DNS). That is, it will find out the name(s) of the mail server(s) accepting email for a given email address or domain.
The bean will attempt to automatically determine the name of a DNS server
from the system settings or from the value of the DNSServer
property.
The bean operates in synchronous or asynchronous mode, depending on the
value of the Timeout
property. Calling the Resolve
method makes the bean
query the DNSServer
. The Response
event is fired for each server
that handles mail for the email address. The bean will fill out the MailServer
property with the most preferred mail server and the Status
property to
"Ok" or an error message.
The RequestId
property may be used to identify requests and is used in the Response
event. The user may set its value before sending out requests, and then match the responses to
the request using the RequestId parameter in the Response
event.
Constructor Summary | |
---|---|
Mx()
Creates an instance of Mx Bean. |
|
Mx(java.lang.String runtimeLicense)
Creates an instance of Mx Bean with specified run-time license. |
Method Summary | |
---|---|
void |
addMxEventListener(MxEventListener l)
|
java.lang.String |
config(java.lang.String configurationString)
Sets or retrieves a configuration setting. |
void |
doEvents()
Processes events from the internal message queue. |
int |
getDNSPort()
The port where the DNS server is listening. |
java.lang.String |
getDNSServer()
The address of the DNS server. |
java.lang.String |
getLocalHost()
The name of the local host or user-assigned IP interface through which connections are initiated or accepted. |
java.lang.String |
getMailServer()
Mail server with lowest precedence value (lowest cost to reach). |
int |
getRequestId()
Identifies each request. |
java.lang.String |
getStatus()
Status of the request is empty while in progress, 'OK' or error message upon completion. |
int |
getTimeout()
A timeout for the bean. |
void |
interrupt()
Interrupt the current method. |
boolean |
isIdle()
The current status of the component. |
void |
removeMxEventListener(MxEventListener l)
|
void |
resolve(java.lang.String emailAddress)
Resolves an email address. |
void |
setDNSPort(int DNSPort)
The port where the DNS server is listening. |
void |
setDNSServer(java.lang.String DNSServer)
The address of the DNS server. |
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 |
setRequestId(int requestId)
Identifies each request. |
void |
setTimeout(int timeout)
A timeout for the bean. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Mx()
public Mx(java.lang.String runtimeLicense)
Method Detail |
---|
public int getDNSPort()
This property contains the port where the DNS server is listening. The default value is 53 but you may set this property to any other value for use with experimental servers, etc.
public void setDNSPort(int DNSPort) throws IPWorksException
This property contains the port where the DNS server is listening. The default value is 53 but you may set this property to any other value for use with experimental servers, etc.
IPWorksException
public java.lang.String getDNSServer()
This property contains the address of the DNS server. The bean attempts to find the default DNS server for the machine where it is installed, and provide it in the DNSServer
property. You may later change it to any particular DNS server you want to query.
While any internet host running a DNS service will suffice, it is preferable to use either the DNS server for your network or the DNS server for the domain which you are querying.
If the bean cannot determine the default DNS server address, the property value will be an empty string.
NOTE: Automatic discovery of the default DNS server is not supported in the Java edition.
public void setDNSServer(java.lang.String DNSServer) throws IPWorksException
This property contains the address of the DNS server. The bean attempts to find the default DNS server for the machine where it is installed, and provide it in the DNSServer
property. You may later change it to any particular DNS server you want to query.
While any internet host running a DNS service will suffice, it is preferable to use either the DNS server for your network or the DNS server for the domain which you are querying.
If the bean cannot determine the default DNS server address, the property value will be an empty string.
NOTE: Automatic discovery of the default DNS server is not supported in the Java edition.
IPWorksException
public boolean isIdle()
Idle
will be False if the component is currently busy (communicating
and/or waiting for an answer), and True at all other times.
public java.lang.String getLocalHost()
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.
public void setLocalHost(java.lang.String localHost) throws IPWorksException
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.
IPWorksException
public java.lang.String getMailServer()
This property contains the mail server with lowest precedence value (lowest cost to reach). After all events are fired this property holds
the name of the best mail server for the supplied email address, and
the Status
property holds the completion status.
public int getRequestId()
This property identifies each request. This may be useful if several email addresses need to be resolved.
Each request may be identified by the user before starting a query
by calling the Resolve
method.
If a custom value is needed for RequestId
, the property must be set
before resolving an email address. The bean increments RequestId
automatically after sending each request.
public void setRequestId(int requestId) throws IPWorksException
This property identifies each request. This may be useful if several email addresses need to be resolved.
Each request may be identified by the user before starting a query
by calling the Resolve
method.
If a custom value is needed for RequestId
, the property must be set
before resolving an email address. The bean increments RequestId
automatically after sending each request.
IPWorksException
public java.lang.String getStatus()
This property is reset each time the Resolve
method is called. When
a response comes from the DNSServer
this
property is set to "OK" in case of success or to an error message as described
in the Response
event.
public int getTimeout()
If the Timeout
property is set to 0, all operations return
immediately, potentially failing with an error if they can't be
completed immediately.
If Timeout
is set to a positive value, the bean will
wait for the operation to complete before returning control.
The bean will use DoEvents
to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If Timeout
expires, and the operation is not yet complete,
the bean throws an exception.
Please note that by default, all timeouts are inactivity timeouts ,
i.e. the timeout period is extended by Timeout
seconds when
any amount of data is successfully sent or received.
Optionally, the behavior of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum
of Timeout
seconds since the beginning of the operation, without
extending the timeout period during communications.
This behavior is controlled by the AbsoluteTimeout
configuration setting.
The default value for the Timeout
property is 60 seconds.
public void setTimeout(int timeout) throws IPWorksException
If the Timeout
property is set to 0, all operations return
immediately, potentially failing with an error if they can't be
completed immediately.
If Timeout
is set to a positive value, the bean will
wait for the operation to complete before returning control.
The bean will use DoEvents
to enter an efficient wait loop
during any potential waiting period, making sure that all system events
are processed immediately as they arrive. This ensures that the host
application does not "freeze" and remains responsive.
If Timeout
expires, and the operation is not yet complete,
the bean throws an exception.
Please note that by default, all timeouts are inactivity timeouts ,
i.e. the timeout period is extended by Timeout
seconds when
any amount of data is successfully sent or received.
Optionally, the behavior of the bean may be changed to absolute timeouts , i.e. the bean will wait for a maximum
of Timeout
seconds since the beginning of the operation, without
extending the timeout period during communications.
This behavior is controlled by the AbsoluteTimeout
configuration setting.
The default value for the Timeout
property is 60 seconds.
IPWorksException
public java.lang.String config(java.lang.String configurationString) throws IPWorksException
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.
Note: This setting is only available in Windows.
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
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
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.
Active
property or it will have no effect.The default value for this setting is False.
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.
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.
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.
IPWorksException
public void doEvents() throws IPWorksException
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.
IPWorksException
public void interrupt() throws IPWorksException
If there is no method in progress, Interrupt
simply returns, doing nothing.
IPWorksException
public void resolve(java.lang.String emailAddress) throws IPWorksException
This method resolves an email address. Calling this method directs the bean to query DNSServer
at port DNSPort
about MX records related to EmailAddress .
The server's response is provided through one or more Response
events.
After the query completes, the MailServer
property is set to the best mail server and the Status
property has the result description of the response.
Valid queries are email addresses like name@company.com or hostnames and domains like domain.com .
Example (Determine Top Priority Mail Server of Email Address)
MXControl.Resolve "email@server.com"
While MXControl.MailServer = ""
\011MXControl.DoEvents()
End While
BestMailServer = MXControl.MailServer
IPWorksException
public void addMxEventListener(MxEventListener l) throws java.util.TooManyListenersException
java.util.TooManyListenersException
public void removeMxEventListener(MxEventListener l)
|
IP*Works! V9 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |