I love the smell of UnrealEd crashing in the morning. – tarquin
UE2:TcpLink (UT2003)
Object >> Actor >> Info >> InternetInfo >> InternetLink >> TcpLink |
Contents
- Package:
- IpDrv
- Direct subclasses:
- BufferedTcpLink, WebConnection, WebServer
- This class in other games:
- RTNP, UT, U1, UE2Runtime, U2, U2XMP, UT2004, UT3, UDK
TcpLink: An Internet TCP/IP connection.
See the parent class InternetLink for additional members required to use this class.
Properties[edit]
AcceptClass[edit]
Type: class<TcpLink>
When in listening mode and this property specifies another TcpLink class, a new instance of that class is spawned with the listening instance as Actor.Owner whenever a connection is accepted.
LinkState[edit]
Type: ELinkState
The current link state of this TCP socket.
RemoteAddr[edit]
Type: InternetLink.IpAddr
The remote side's IP address and TCP port when this instance is connected. (Not applicable for listening sockets with an AcceptClass.
SendFIFO[edit]
Modifiers: const
An internal buffer for data to send. The TcpLink will try to flush any data to the underlying socket immediately, but if the socket can't handle all data, it may be stored here until the next attempt.
Default values[edit]
Property | Value |
---|---|
bAlwaysTick | True |
Enums[edit]
ELinkState[edit]
This enumeration contains possible link states of the TCP socket.
- STATE_Initialized
- Sockets is initialized. This is the initial state when the TcpLink is spawned.
- STATE_Ready
- Port bound, ready for activity. This state is set when the BindPort() function returns successfully.
- STATE_Listening
- Listening for connections. This state is set when the Listen() function returns successfully.
- STATE_Connecting
- Attempting to connect. This state indicates that a previous Open() call was successful, but the connection is not yet established.
- STATE_Connected
- Open and connected. This state indicates that the background operations initiated by a previous Open() call have successfully completed or a connection was accepted in listening state and the connection is now established.
- STATE_ListenClosePending
- Socket in process of closing. This state is set after a Close() call on a listening socket that had previously established a connection.
- STATE_ConnectClosePending
- Socket in process of closing. This state is set after a Close() call on a non-listening socket (i.e. the connection was established via Open() or by spawning a new TcpLink for an accepted connection) that had previously established a connection.
- STATE_ListenClosing
- Socket in process of closing. This state is set after a Close() call on a listening socket without a connections.
- STATE_ConnectClosing
- Socket in process of closing. This state is set when the close-pending connection was shut down.
Functions[edit]
Native functions[edit]
BindPort[edit]
Binds a local TCP port for this socket. This function must be called once before using Open() or Listen(). Specifying a port is recommended if you plan to listen for incoming connections. However, if you want to connect to a remote listening socket, specifying a port is actually counter-productive, since you usually don't care which local port is bound on the client side.
Close[edit]
Closes a connection or stops listening for connections.
IsConnected[edit]
Returns whether the TCP socket is currently connected.
Listen[edit]
Starts listening for incoming connection attempts on the previously bound port.
Open[edit]
Opens a connection to the specifies remote IP address and TCP port using the previously bound port as local port.
ReadBinary[edit]
Attempts to read the specified number of bytes into the provided buffer and returns the actual number of bytes read. (Don't specify a count greater than 255, unless you want to risk breaking things!)
You should not use this function when the TcpLink is in InternetLink.ReceiveMode = RMODE_Event
.
ReadText[edit]
Reads all pending received bytes and interprets them as Windows-1252 encoded string. If the receive buffer contains null bytes, the returned string will be truncated at the first such byte, but the receive buffer is emptied anyway, so part of the data may be lost. (Use ReadBinary() if you expect binary data to be received.)
You should not use this function when the TcpLink is in InternetLink.ReceiveMode = RMODE_Event
.
SendBinary[edit]
Sends the specified number of bytes from the provided buffer. (Like with ReadBinary(), the count is not checked, so make sure it never exceeds 255!)
SendText[edit]
Sends the specified string, assuming Windows-1252 encoding. That means if the string contains character codes greater than 255, those characters' high bytes will be lost!
Events[edit]
Accepted[edit]
This event is called on the AcceptClass instance spawned when a connection is accepted by a listening socket.
Closed[edit]
Called when a connection was closed.
Opened[edit]
Called when a connection was opened.
ReceivedBinary[edit]
Called in InternetLink.ReceiveMode = RMODE_Event
when the InternetLink.LinkMode is MODE_Binary
and new data was received.
ReceivedLine[edit]
Called in InternetLink.ReceiveMode = RMODE_Event
when the InternetLink.LinkMode is MODE_Line
and a new line was received. The end of the line type is defined by the InternetLink.InLineMode property.
ReceivedText[edit]
Called in InternetLink.ReceiveMode = RMODE_Event
when the InternetLink.LinkMode is MODE_Text
and new data was received.