home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / IpDrv / Classes / TcpLink.uc < prev    next >
Text File  |  2003-10-22  |  4KB  |  105 lines

  1. //=============================================================================
  2. // TcpLink: An Internet TCP/IP connection.
  3. //=============================================================================
  4. class TcpLink extends InternetLink
  5.     native
  6.     transient;
  7.  
  8. cpptext
  9. {
  10.     ATcpLink();
  11.     void PostScriptDestroyed();
  12.     UBOOL Tick( FLOAT DeltaTime, enum ELevelTick TickType );    
  13.  
  14.     void CheckConnectionAttempt();
  15.     void CheckConnectionQueue();
  16.     void PollConnections();
  17.     UBOOL FlushSendBuffer();
  18.     void ShutdownConnection();
  19.     virtual UBOOL ShouldTickInEntry() { return true; }
  20. }
  21.  
  22. //-----------------------------------------------------------------------------
  23. // Variables.
  24.  
  25. // LinkState is only valid for TcpLink at this time.
  26. var enum ELinkState
  27. {
  28.     STATE_Initialized,        // Sockets is initialized
  29.     STATE_Ready,            // Port bound, ready for activity
  30.     STATE_Listening,        // Listening for connections
  31.     STATE_Connecting,        // Attempting to connect
  32.     STATE_Connected,        // Open and connected
  33.     STATE_ListenClosePending,// Socket in process of closing
  34.     STATE_ConnectClosePending,// Socket in process of closing
  35.     STATE_ListenClosing,    // Socket in process of closing
  36.     STATE_ConnectClosing    // Socket in process of closing
  37. } LinkState;
  38.  
  39. var IpAddr      RemoteAddr;    // Contains address of peer connected to from a Listen()
  40.  
  41. // If AcceptClass is not None, an actor of class AcceptClass will be spawned when an
  42. // incoming connecting is accepted, leaving the listener open to accept more connections.
  43. // Accepted() is called only in the child class.  You can use the LostChild() and GainedChild()
  44. // events to track your children.
  45. var class<TcpLink> AcceptClass;
  46. var const Array<byte> SendFIFO; // send fifo
  47. //-----------------------------------------------------------------------------
  48. // natives.
  49.  
  50. // BindPort: Binds a free port or optional port specified in argument one.
  51. native function int BindPort( optional int Port, optional bool bUseNextAvailable );
  52.  
  53. // Listen: Listen for connections.  Can handle up to 5 simultaneous connections.
  54. // Returns false if failed to place socket in listen mode.
  55. native function bool Listen();
  56.  
  57. // Open: Open a connection to a foreign host.
  58. native function bool Open( IpAddr Addr );
  59.  
  60. // Close: Closes the current connection.   
  61. native function bool Close();
  62.  
  63. // IsConnected: Returns true if connected.
  64. native function bool IsConnected();
  65.  
  66. // SendText: Sends text string. 
  67. // Appends a cr/lf if LinkMode=MODE_Line.  Returns number of bytes sent.
  68. native function int SendText( coerce string Str );
  69.  
  70. // SendBinary: Send data as a byte array.
  71. native function int SendBinary( int Count, byte B[255] );
  72.  
  73. // ReadText: Reads text string.
  74. // Returns number of bytes read.  
  75. native function int ReadText( out string Str );
  76.  
  77. // ReadBinary: Read data as a byte array.
  78. native function int ReadBinary( int Count, out byte B[255] );
  79.  
  80. //-----------------------------------------------------------------------------
  81. // Events.
  82.  
  83. // Accepted: Called during STATE_Listening when a new connection is accepted.
  84. event Accepted();
  85.  
  86. // Opened: Called when socket successfully connects.
  87. event Opened();
  88.  
  89. // Closed: Called when Close() completes or the connection is dropped.
  90. event Closed();
  91.  
  92. // ReceivedText: Called when data is received and connection mode is MODE_Text.
  93. event ReceivedText( string Text );
  94.  
  95. // ReceivedLine: Called when data is received and connection mode is MODE_Line.
  96. event ReceivedLine( string Line );
  97.  
  98. // ReceivedBinary: Called when data is received and connection mode is MODE_Binary.
  99. event ReceivedBinary( int Count, byte B[255] );
  100.  
  101. defaultproperties
  102. {
  103.      bAlwaysTick=True
  104. }
  105.