TcpLink class library reference
Below is a summary of all the TcpLink Class Library Reference available for .NET in HostFront 5.0
Note
Before starting to use the TcpLink class, make sure that your cluster is configured with a persistent port. For more information, see the Cluster Properties in the Administrator's Guide.
Table 8: HostFront .NET TcpLink class library
Associated methods Associated properties
Attach (System.String,System.NET.IPEndPoint,System.Boolean bUseCluster)
Attach (System.String,System.NET.IPEndPoint)
Close
Connect (System.String,System.String,System.NET.IPEndPoint,System.Boolean bUseCluster)
Connect (System.NET.IPEndPoint)
Connect (System.NET.IPEndPoint, System.Boolean)
Connect (System.String,System.String,System.NET.IPEndPoint)
Detach
GetConnectionInfo
IsConnected
PushKey (HostFront.EAI.Key,System.Int32)
PushKey (HostFront.EAI.Key,HostFront.EAI.ScreenIdentifierSystem.Int32)
PushKey (HostFront.EAI.Key,HostFront.EAI.ScreenIdentifier)
PushKey (HostFront.EAI.Key)
PushKey (System.Int32,System.Int32)
PushKey (System.Int32,HostFront.EAI.ScreenIdentifier,System.Int32)
PushKey (System.Int32,HostFront.EAI.ScreenIdentifier)
PushKey (System.Int32)
ReceiveTimeOut
SendTimeOut
TcpLink (HostFront.EAI.Emulation)
IsConnected
ReceiveTimeout
SendTimeout
Methods
The following methods are associated with the TcpLink class.
Attach (System.String,System.NET.IPEndPoint, System.Boolean bUseCluster)
Allows the object to "attach" to an already existing session on the host.
Note
This method should be used for version prior to 3.6.x.
Prototype
public virtual System.Boolean Attach (System.String sessionID,System.NET.IPEndPoint hostIP)
Member of HostFront.EAI.TcpLink
Parameters
SessionID: The host session id to attach to.
HostIP: The IP address and port number of the HostFront server that handles the live connection to the host.
bUseCluster : True of use the cluster architecture (HFEE) or false for versions prior to 3.6.x. If set to True, the method resolves to the normal Attach(System.String,System.NET.IPEndPoint) method.
Return
Returns true if successful, false otherwise.
If False, then the ErrorMessage property can have the following values:
•  20 — The provided session ID is unknown, meaning that either the session has been disconnected (by the backend host or for any other reason) or that the provided session ID is a wrong one.
•  21 — The session exists but is already attached.
Attach (System.String,System.NET.IPEndPoint)
Allows the object to "attach" to an already existing session on the host.
Prototype
public virtual System.Boolean Attach (System.String sessionID,System.NET.IPEndPoint hostIP)
Member of HostFront.EAI.TcpLink
Parameters
SessionID: The host session id to attach to.
HostIP: The IP address and port number of the HostFront server that handles the live connection to the host.
Return
Returns true if successful, false otherwise.
Close
Closes the connection to HostFront server and terminates the session on the host.
Prototype
public virtual void Close ( )
Member of HostFront.EAI.TcpLink
Connect (System.String,System.String,System.NET.IPEndPoint,System.Boolean bUseCluster)
Creates a TCP/IP connection to the host by first logging into HostFront server or the cluster service.
Note
This method should be used for version prior to 3.6.0.
Prototype
public virtual System.Boolean Connect (System.String username,System.String password,System.NET.IPEndPoint hostIP)
Member of HostFront.EAI.TcpLink
Parameters
Username: The HostFront server username.
Password: The HostFront server password.
HostIP: The IP address and port used to connect to HostFront server or cluster service.
bUseCluster : True of use the cluster architecture (HFEE) or false for versions prior to 3.6.0. If set to True, the method resolves to the normal Connect(System.String,System.String, System.NET.IPEndPoint) method.
Return
Returns true if successful, false otherwise.
Connect (System.NET.IPEndPoint)
Creates a TCP/IP connection to the host by first logging into the Cluster Service using the Windows domain account of the current user on the machine running the integration component.
Prototype
public virtual System.Boolean Connect (System.NET.IPEndPoint hostIP)
Member of HostFront.EAI.TcpLink
Parameters
HostIP: The IP address and port used to connect to the cluster service.
Return
Returns true if successful, false otherwise.
If False, then the ErrorMessage property can have the following values:
•  20 — The session could not connect to the backend host. Check the event log on the HostFront server.
•  24 — The session did connect but was disconnected either by the backend host or by the HostFront server. Check the event log on the HostFront server.
Connect (System.NET.IPEndPoint, System.Boolean)
Creates a TCP connection to the host by first logging into the cluster service using the impersonated Windows domain account of the calling user on the machine making the call.
Prototype
public virtual System.Boolean Connect ( System.NET.IPEndPoint hostIP, System.Boolean bImpersonated )
Member of HostFront.EAI.TcpLink
Parameters
hostIP : The IP address and port used to connect to the cluster service.
bImpersonated : A Boolean value. When True, it indicates using Impersonation.
Return
Returns true if successful. False otherwise.
Example
The following example demonstrates how to use this Connect method with impersonation in a web service.
1. Impersonating in Web Service:
In the Web.config file (in the project of Web Service) add:
<authentication mode="Windows" /> 

<identity impersonate="true"/> 
2. Setting of IIS:
At the virtual directory of the Web Service project, uncheck “Enable anonymous access” and check “Integrated Windows authentication”
3. Setting of IE:
IE à Tools à Internet Options à Advanced à Security à check “Enable Integrated Windows Authentication (requires restart)”
4. Code snippet of impersonation in Web Service:
[WebMethod] 
      public string TestTCP2(string sServer, string sPort) 
      { 
            System.Security.Principal.WindowsImpersonationContext ctxt = null; 
            try 
            { 
                  //impersonating 
                  System.Security.Principal.WindowsIdentity identity = 
(System.Security.Principal.WindowsIdentity)User.Identity; 
                  ctxt = identity.Impersonate(); 
            string s = WindowsIdentity.GetCurrent().Name; 
  
                  //sServer = Cluser Service ip, sPort = Cluster Service port 
HostFront.EAI.TcpLink hostFront = new HostFront.EAI.TcpLink(HostFront.EAI.Emulation.HFM3270); 
  
IPEndPoint end = new IPEndPoint(System.Net.IPAddress.Parse(sServer), Int32.Parse(sPort)); 
  
                  //connect to hostfront by specifing impersonation 
                  hostFront.Connect(end,true); 
            if(hostFront.IsConnected) 
                  { 
                        return hostFront.ScreenToString(); 
                  } 
                  else 
                  { 
                        return hostFront.ErrorMessage; 
                  } 
            } 
            catch(Exception ex) 
            { 
                  return ex.ToString(); 
            } 
            finally 
            { 
                  ctxt.Undo(); 
            } 
      } 
5. Code snippet of Client of Web Service:
EAI.Service1 ws = new EAI.Service1(); 
ws.Credentials = new System.Net.NetworkCredential(this.txtName.Text, 
                              this.txtPSW.Text); 
ws.PreAuthenticate = true; 
            
this.listBox1.Items.Add(ws.TestTCP2(this.textBox1.Text)); 
Note
If your Web Service needs to access other resources on behalf of client, or "Access Denied" error message occurs, you might consider using a solution as follow in your Web Services with impersonation: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q325791
Connect (System.String,System.String,System.NET.IPEndPoint)
Creates a TCP/IP connection to the host by first logging into the Cluster Service.
Prototype
public virtual System.Boolean Connect (System.String username,System.String password,System.NET.IPEndPoint hostIP)
Member of HostFront.EAI.TcpLink
Parameters
Username: The HostFront server username.
Password: The HostFront server password.
HostIP: The IP address and port used to connect to the cluster service.
Return
Returns true if successful, false otherwise.
If False, then the ErrorMessage property can have the following values:
•  20 — The session could not connect to the backend host. Check the event log on the HostFront server.
•  24 — The session did connect but was disconnected either by the backend host or by the HostFront server. Check the event log on the HostFront server.
Detach
Closes the connection to HostFront server but does not terminate the session on the host.
Prototype
public virtual System.String Detach ( )
Member of HostFront.EAI.TcpLink
Return
The ConnectionInfo structure indicating the returned values.
IsConnected
Indicates whether the connection to the host is still valid.
Prototype
public bool IsConnected [ get]
Member of HostFront.EAI.TcpLink
PushKey (HostFront.EAI.Key,System.Int32)
Issues a key press command on the host. The final screen is obtained after a specified delay. Used mostly with 3270 emulation.
Prototype
Member of HostFront.EAI.HostLink
Parameters
key: The value of the key to execute on the host.
millisecondsDelay: The delay specified in milliseconds.
Return
Returns true if the specified time has not elapsed. Otherwise, false.
PushKey (HostFront.EAI.Key,HostFront.EAI.ScreenIdentifierSystem.Int32)
Issues a key press command on the host. Terminates when a screen field is equal to the screen identifier or when the specified time elapses.
Prototype
Member of HostFront.EAI.HostLink
Parameters
key: The value of the key to execute on the host.
id: The screen identifier.
millisecondsTimeout: The timeout specified in milliseconds. A value of 0 indicates an infinite wait.
Return
Returns true if the specified time has not elapsed. Otherwise, false.
PushKey (HostFront.EAI.Key, HostFront.EAI.ScreenIdentifier)
Issues a key press command on the host. Terminates when a screen field is equal to the screen identifier. Used mostly with 3270 emulation. This is an abstract method.
Prototype
public abstract virtual System.Boolean PushKey (HostFront.EAI.Key key,HostFront.EAI.ScreenIdentifier id)
Member of HostFront.EAI.HostLink
Parameters
key: The value of the key to execute on the host.
id: The screen identifier.
Return
Indicates whether the operation was successful.
PushKey (HostFront.EAI.Key)
Issues a key press command on the host.
Prototype
public abstract virtual System.Boolean PushKey (HostFront.EAI.Key key)
Member of HostFront.EAI.HostLink
Parameters
key: The value of the key to execute on the host.
Return
Indicates whether the operation was successful.
PushKey (System.Int32,System.Int32)
Issues a key press command on the host. The final screen is obtained after a specified delay. Used mostly with 3270 emulation.
Prototype
Member of HostFront.EAI.HostLink
Parameters
key: The value of the key to execute on the host.
millisecondsDelay: The delay specified in milliseconds.
Return
Returns true if the specified time has not elapsed. Otherwise, false.
PushKey (System.Int32,HostFront.EAI.ScreenIdentifier,System.Int32)
Issues a key press command on the host. Terminates when a screen field is equal to the screen identifier or when the specified time elapses.
Prototype
Member of HostFront.EAI.HostLink
Parameters
key: The value of the key to execute on the host.
id: The screen identifier.
millisecondsTimeout: The timeout specified in milliseconds. A value of 0 indicates an infinite wait.
Return
Returns true if the specified time has not elapsed. Otherwise, false.
PushKey (System.Int32,HostFront.EAI.ScreenIdentifier)
Issues a key press command on the host. Terminates when a screen field is equal to the screen identifier. Used mostly with 3270 emulation. This is an abstract method.
Prototype
public abstract virtual System.Boolean PushKey (System.Int32 key,HostFront.EAI.ScreenIdentifier id)
Member of HostFront.EAI.HostLink
Parameters
Key: The value of the key to execute on the host.
Id: The screen identifier.
Return
Returns true if successful, false otherwise.
PushKey (System.Int32)
Issues a key press command on the host. This is an abstract method.
Prototype
public abstract virtual System.Boolean PushKey (System.Int32 key)
Member of HostFront.EAI.HostLink
Parameters
Key: The value of the key to execute on the host.
Return
Returns true if successful, false otherwise.
ReceiveTimeout
Gets or sets the amount of time a TcpLink will wait to receive data once initiated. The time-out value is in milliseconds.
Prototype
public int ReceiveTimeout [ get, set ]
Member of HostFront.EAI.TcpLink
SendTimeout
Gets or sets the amount of time a TcpLink will wait to receive confirmation after you initiate a send. The time-out value is in milliseconds.
Prototype
public int SendTimeout [ get, set ]
Member of HostFront.EAI.TcpLink
TcpLink (HostFront.EAI.Emulation)
Initializes a new instance of the TcpLink class.
Prototype
public TcpLink (HostFront.EAI.Emulation emulation)
Member of HostFront.EAI.TcpLink
Parameters
emulation: The type of emulation run the target HostFront service.
Properties
The following properties are associated with the TcpLink class.
IsConnected
Indicates whether the connection to the host is still valid.
Prototype
public bool IsConnected [ get]
Member of HostFront.EAI.TcpLink
ReceiveTimeout
Gets or sets the amount of time a TcpLink will wait to receive data once initiated. The time-out value is in milliseconds.
Prototype
public int ReceiveTimeout [ get, set ]
Member of HostFront.EAI.TcpLink
SendTimeout
Gets or sets the amount of time a TcpLink will wait to receive confirmation after you initiate a send. The time-out value is in milliseconds.
Prototype
public int SendTimeout [ get, set ]
Member of HostFront.EAI.TcpLink
TcpTrace class
This class displays the screen content within a window. It should only be used for debugging purposes. It implements all the TcpLink class functionality.