## IpDrv
Class TcpLink

source: C:\XIII\IpDrv\Classes\TcpLink.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Info
             |
             +--Engine.InternetInfo
                |
                +--IpDrv.InternetLink
                   |
                   +--IpDrv.TcpLink

Direct Known Subclasses:WebConnection, WebServer

class TcpLink
extends IpDrv.InternetLink

    //=============================================================================
    // TcpLink: An Internet TCP/IP connection.
    //=============================================================================

Variables
`class` | `AcceptClass` Contains address of peer connected to from a Listen()
`enum` | `ELinkState`
`IpAddr` | `RemoteAddr` Contains address of peer connected to from a Listen()
`Array` | `SendFIFO` send fifo

Function Summary
`int` | `BindPort(optional int, optional bool)`
    // BindPort: Binds a free port or optional port specified in argument one.
`bool` | `Close()`
    // Close: Closes the current connection.
`bool` | `IsConnected()`
    // IsConnected: Returns true if connected.
`bool` | `Listen()`
    // Listen: Listen for connections.  Can handle up to 5 simultaneous connections.
    // Returns false if failed to place socket in listen mode.
`bool` | `Open(IpAddr Addr)`
    // Open: Open a connection to a foreign host.
`int` | `ReadText(out string)`
    // ReadText: Reads text string.
    // Returns number of bytes read.
`int` | `SendText(string Str)`
    // SendText: Sends text string.
    // Appends a cr/lf if LinkMode=MODE_Line.  Returns number of bytes sent.

Source Code

    00001	//=============================================================================
    00002	// TcpLink: An Internet TCP/IP connection.
    00003	//=============================================================================
    00004	class TcpLink extends InternetLink
    00005		native
    00006		transient;
    00007
    00008	//-----------------------------------------------------------------------------
    00009	// Variables.
    00010
    00011	// LinkState is only valid for TcpLink at this time.
    00012	var enum ELinkState
    00013	{
    00014		STATE_Initialized,		// Sockets is initialized
    00015		STATE_Ready,			// Port bound, ready for activity
    00016		STATE_Listening,		// Listening for connections
    00017		STATE_Connecting,		// Attempting to connect
    00018		STATE_Connected,		// Open and connected
    00019		STATE_ListenClosePending,// Socket in process of closing
    00020		STATE_ConnectClosePending,// Socket in process of closing
    00021		STATE_ListenClosing,	// Socket in process of closing
    00022		STATE_ConnectClosing	// Socket in process of closing
    00023	} LinkState;
    00024
    00025	var IpAddr	  RemoteAddr;	// Contains address of peer connected to from a Listen()
    00026
    00027	// If AcceptClass is not None, an actor of class AcceptClass will be spawned when an
    00028	// incoming connecting is accepted, leaving the listener open to accept more connections.
    00029	// Accepted() is called only in the child class.  You can use the LostChild() and GainedChild()
    00030	// events to track your children.
    00031	var class<TcpLink> AcceptClass;
    00032	var const Array<byte> SendFIFO; // send fifo
    00033	//-----------------------------------------------------------------------------
    00034	// natives.
    00035
    00036	// BindPort: Binds a free port or optional port specified in argument one.
    00037	native(690) static final function int BindPort( optional int Port, optional bool bUseNextAvailable );
    00038
    00039	// Listen: Listen for connections.  Can handle up to 5 simultaneous connections.
    00040	// Returns false if failed to place socket in listen mode.
    00041	native(689) static final function bool Listen();
    00042
    00043	// Open: Open a connection to a foreign host.
    00044	native(688) static final function bool Open( IpAddr Addr );
    00045
    00046	// Close: Closes the current connection.
    00047	native(687) static final function bool Close();
    00048
    00049	// IsConnected: Returns true if connected.
    00050	native(686) static final function bool IsConnected();
    00051
    00052	// SendText: Sends text string.
    00053	// Appends a cr/lf if LinkMode=MODE_Line.  Returns number of bytes sent.
    00054	native(685) static final function int SendText( coerce string Str );
    00055
    00056	// SendBinary: Send data as a byte array.
    00057	native(684) static final function int SendBinary( int Count, byte B[255] );
    00058
    00059	// ReadText: Reads text string.
    00060	// Returns number of bytes read.
    00061	native(683) static final function int ReadText( out string Str );
    00062
    00063	// ReadBinary: Read data as a byte array.
    00064	native(682) static final function int ReadBinary( int Count, out byte B[255] );
    00065
    00066	//-----------------------------------------------------------------------------
    00067	// Events.
    00068
    00069	// Accepted: Called during STATE_Listening when a new connection is accepted.
    00070	event Accepted();
    00071
    00072	// Opened: Called when socket successfully connects.
    00073	event Opened();
    00074
    00075	// Closed: Called when Close() completes or the connection is dropped.
    00076	event Closed();
    00077
    00078	// ReceivedText: Called when data is received and connection mode is MODE_Text.
    00079	event ReceivedText( string Text );
    00080
    00081	// ReceivedLine: Called when data is received and connection mode is MODE_Line.
    00082	event ReceivedLine( string Line );
    00083
    00084	// ReceivedBinary: Called when data is received and connection mode is MODE_Binary.
    00085	event ReceivedBinary( int Count, byte B[255] );
    00086
    00087	defaultproperties
    00088	{
    00089	     bAlwaysTick=True
    00090	}

End Source Code