Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

IpDrv.TcpLink


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
//=============================================================================
// TcpLink: An Internet TCP/IP connection.
//=============================================================================
class TcpLink extends InternetLink
	native
	transient;

cpptext
{
	ATcpLink();
	void PostScriptDestroyed();
	UBOOL Tick( FLOAT DeltaTime, enum ELevelTick TickType );	

	void CheckConnectionAttempt();
	void CheckConnectionQueue();
	void PollConnections();
	UBOOL FlushSendBuffer();
	void ShutdownConnection();
	virtual UBOOL ShouldTickInEntry() { return true; }
}

//-----------------------------------------------------------------------------
// Variables.

// LinkState is only valid for TcpLink at this time.
var enum ELinkState
{
	STATE_Initialized,		// Sockets is initialized
	STATE_Ready,			// Port bound, ready for activity
	STATE_Listening,		// Listening for connections
	STATE_Connecting,		// Attempting to connect
	STATE_Connected,		// Open and connected
	STATE_ListenClosePending,// Socket in process of closing
	STATE_ConnectClosePending,// Socket in process of closing
	STATE_ListenClosing,	// Socket in process of closing
	STATE_ConnectClosing	// Socket in process of closing
} LinkState;

var IpAddr	  RemoteAddr;	// Contains address of peer connected to from a Listen()

// If AcceptClass is not None, an actor of class AcceptClass will be spawned when an
// incoming connecting is accepted, leaving the listener open to accept more connections.
// Accepted() is called only in the child class.  You can use the LostChild() and GainedChild()
// events to track your children.
var class<TcpLink> AcceptClass;
var const Array<byte> SendFIFO; // send fifo
var const string RecvBuf; // Recveive buffer (only used with MODE_Line)
//-----------------------------------------------------------------------------
// natives.

// BindPort: Binds a free port or optional port specified in argument one.
native function int BindPort( optional int Port, optional bool bUseNextAvailable );

// Listen: Listen for connections.  Can handle up to 5 simultaneous connections.
// Returns false if failed to place socket in listen mode.
native function bool Listen();

// Open: Open a connection to a foreign host.
native function bool Open( IpAddr Addr );

// Close: Closes the current connection.   
native function bool Close();

// IsConnected: Returns true if connected.
native function bool IsConnected();

// SendText: Sends text string. 
// Appends a cr/lf if LinkMode=MODE_Line.  Returns number of bytes sent.
native function int SendText( coerce string Str );

// SendBinary: Send data as a byte array.
native function int SendBinary( int Count, byte B[255] );

// ReadText: Reads text string.
// Returns number of bytes read.  
native function int ReadText( out string Str );

// ReadBinary: Read data as a byte array.
native function int ReadBinary( int Count, out byte B[255] );

//-----------------------------------------------------------------------------
// Events.

// Accepted: Called during STATE_Listening when a new connection is accepted.
event Accepted();

// Opened: Called when socket successfully connects.
event Opened();

// Closed: Called when Close() completes or the connection is dropped.
event Closed();

// ReceivedText: Called when data is received and connection mode is MODE_Text.
event ReceivedText( string Text );

// ReceivedLine: Called when data is received and connection mode is MODE_Line.
// \r\n is stripped from the line
event ReceivedLine( string Line );

// ReceivedBinary: Called when data is received and connection mode is MODE_Binary.
event ReceivedBinary( int Count, byte B[255] );

defaultproperties
{
     bAlwaysTick=True
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Di 5.9.2006 22:29:04.000 - Creation time: Do 14.8.2014 09:58:51.764 - Created with UnCodeX