IP*Works!

ipworks
Class Mx

java.lang.Object
  |
  +--ipworks.Mx

public class Mx
extends java.lang.Object

The MX control 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 control will try to find out automatically the name of a DNS server from the system's settings and set the DNSServer property.

The control operates in asynchronous mode: assigning an email address or domain name to EmailAddress property directs the control to query the DNSServer and fire the Response event for each server which handles the mail for the email address and fill out the MailServer property with the most preferred mail server and the Status event to "Ok" or an error message.

RequestId may be used to identify requests and is used in the Response event. The user may set its value before sending out requests.


Constructor Summary
Mx()
           
 
Method Summary
 void addMxEventListener(MxEventListener l)
           
 void fireError(int errorCode, java.lang.String description)
          Information about errors during data delivery.
 void fireResponse(int requestId, java.lang.String domain, java.lang.String mailServer, int precedence, int timeToLive, int statusCode, java.lang.String description)
          Fired for each MailServer accepting email for the domain.
 int getDNSPort()
          The port where the DNS server is listening.
 java.lang.String getDNSServer()
          IP address (or name) of the DNS server to query.
 java.lang.String getEmailAddress()
          Action property triggering a request to DNSServer .
 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: empty while in progress, 'OK' or error message upon completition.
 int getTimeout()
          A timeout for the component.
 void removeMxEventListener(MxEventListener l)
           
 void resolve(java.lang.String emailAddress)
          Resolve an email address.
 void setDNSPort(int DNSPort)
          The port where the DNS server is listening.
 void setDNSServer(java.lang.String DNSServer)
          IP address (or name) of the DNS server to query.
 void setEmailAddress(java.lang.String emailAddress)
          Action property triggering a request to DNSServer .
 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 component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Mx

public Mx()
Method Detail

getDNSPort

public int getDNSPort()
The port where the DNS server is listening. The default value is 53 but you may set DNSPort to any other value for use with experimental servers, etc.


setDNSPort

public void setDNSPort(int DNSPort)
                throws IPWorksException
The port where the DNS server is listening. The default value is 53 but you may set DNSPort to any other value for use with experimental servers, etc.


getDNSServer

public java.lang.String getDNSServer()
IP address (or name) of the DNS server to query. The control attempts to find the default DNS server for the machine where it is installed, and provide it the DNSServer property. You may later change it to any particular DNS server you want to query.

If the control cannot determine the default DNS server address, the property value will be an empty string.


setDNSServer

public void setDNSServer(java.lang.String DNSServer)
                  throws IPWorksException
IP address (or name) of the DNS server to query. The control attempts to find the default DNS server for the machine where it is installed, and provide it the DNSServer property. You may later change it to any particular DNS server you want to query.

If the control cannot determine the default DNS server address, the property value will be an empty string.


getEmailAddress

public java.lang.String getEmailAddress()
Action property triggering a request to DNSServer . Setting EmailAddress directs the control 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 .


setEmailAddress

public void setEmailAddress(java.lang.String emailAddress)
                     throws IPWorksException
Action property triggering a request to DNSServer . Setting EmailAddress directs the control 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 .


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() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control 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 multihomed 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() Winsock call, or if the user has assigned an IP address, the value of that address.

In multihomed hosts (machines with more than one IP interface) setting LocalHost to the value of an interface will make the control initiate connections (or accept in the case of server controls) only through that interface.

If the control 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 multihomed 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.


getMailServer

public java.lang.String getMailServer()
Mail server with lowest precedence value (lowest cost to reach). After all events are fired the MailServer property holds the name of the best mail server for the EmailAddress and the Status property holds the completition status.


getRequestId

public int getRequestId()
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 (setting the EmailAddress property).

If a custom value is needed for RequestId , the property must be set before setting EmailAddress . The control increments RequestId automatically after sending each request.


setRequestId

public void setRequestId(int requestId)
                  throws IPWorksException
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 (setting the EmailAddress property).

If a custom value is needed for RequestId , the property must be set before setting EmailAddress . The control increments RequestId automatically after sending each request.


getStatus

public java.lang.String getStatus()
Status of the request: empty while in progress, 'OK' or error message upon completition. The Status property is reset each time a request is made by setting EmailAddress . When a response comes from the DNSServer the Status property is set to "OK" in case of success or to an error message as described in the Response event.


getTimeout

public int getTimeout()
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control 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 always remains responsive.


setTimeout

public void setTimeout(int timeout)
                throws IPWorksException
A timeout for the component. If the Timeout property is set to 0 (default value) all actions will run uninterrupted until succesful completion, or an error condition is encountered.

If Timeout is set to a positive value, and any action does not complete within Timeout seconds, the action is aborted, and a 'Timeout' error is fired..

The control 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 always remains responsive.


fireError

public void fireError(int errorCode,
                      java.lang.String description)
Information about errors during data delivery. (Called internally to dispatch the event.)
See Also:
MxErrorEvent

fireResponse

public void fireResponse(int requestId,
                         java.lang.String domain,
                         java.lang.String mailServer,
                         int precedence,
                         int timeToLive,
                         int statusCode,
                         java.lang.String description)
Fired for each MailServer accepting email for the domain. (Called internally to dispatch the event.)
See Also:
MxResponseEvent

resolve

public void resolve(java.lang.String emailAddress)
             throws IPWorksException
Resolve an email address. Calling this method is equivalent to setting the EmailAddress property to EmailAddress .


addMxEventListener

public void addMxEventListener(MxEventListener l)
                        throws java.util.TooManyListenersException

removeMxEventListener

public void removeMxEventListener(MxEventListener l)

IP*Works!

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