TCPClient (1.1b)

Summary
TCPClient (1.1b)
_Class_TCPClientObject that simplifiy the creation of Encrypted TCP Client
Properties
server_ipIP Adress of the server
server_portPort number of the server
max_recv_lenmax # of characters to receive (TCPRecv)
TimeoutReceiving timeout (in ms).
Callback_RecvFunction that is called when data (Binary/String) is received from the server
Callback_ReceivingFunction that is called when being receiving data from the server
Callback_LostConnectionFunction that is called when the connection with the server is lost.
Callback_TimedoutFunction that is called when a client is timed out
Functions
_Class_TCPClientClass constructor
ConnectTry to connect to the server specified by server_ip and server_port
DisconnectDisconnect from the server
IsConnectedCheck if the client is connected to a server
SendSend data (Binary/String) to the server
ProcessFunction that calls all the client’s callbacks when events occures (Receiving, Lost connection...)

_Class_TCPClient

Object that simplifiy the creation of Encrypted TCP Client

Summary
Properties
server_ipIP Adress of the server
server_portPort number of the server
max_recv_lenmax # of characters to receive (TCPRecv)
TimeoutReceiving timeout (in ms).
Callback_RecvFunction that is called when data (Binary/String) is received from the server
Callback_ReceivingFunction that is called when being receiving data from the server
Callback_LostConnectionFunction that is called when the connection with the server is lost.
Callback_TimedoutFunction that is called when a client is timed out
Functions
_Class_TCPClientClass constructor
ConnectTry to connect to the server specified by server_ip and server_port
DisconnectDisconnect from the server
IsConnectedCheck if the client is connected to a server
SendSend data (Binary/String) to the server
ProcessFunction that calls all the client’s callbacks when events occures (Receiving, Lost connection...)

Properties

server_ip

IP Adress of the server

server_port

Port number of the server

max_recv_len

max # of characters to receive (TCPRecv)

Timeout

Receiving timeout (in ms).

When this timeout is reached, the buffer is fluched, and the data that was being transfered is lost.

Callback_Recv

Function that is called when data (Binary/String) is received from the server

The function must be as this prototype

_Func($s_bData)
$s_bDataReceived data (Binary/String)

Callback_Receiving

Function that is called when being receiving data from the server

The function must be as this prototype

_Func($BufferLenght)
$BufferLenghtLenght of the client’s receiving buffer (Not equal to the final lenght/size of the received data, it’s just an indication)

Callback_LostConnection

Function that is called when the connection with the server is lost.

Has no parameters

Callback_Timedout

Function that is called when a client is timed out

The function must be as this prototype

_Func($BufferLenght_LostData)
$BufferLenght_LostDataLenght of the buffer when timed out, corresponds to the amount of lost data (because buffer is flushed when time out occures)

See Timeout

Functions

_Class_TCPClient

Class constructor

Parameters

$ipValue to assign to server_ip
$portValue to assign to server_port
$encrypt_pwdData encryption password.  Must be the same as in the server.

Connect

Try to connect to the server specified by server_ip and server_port

Parameters

$cb_RecvValue to assign to Callback_Recv
$cb_ReceivingValue to assign to Callback_Receiving
$cb_LostConnectionValue to assign to Callback_LostConnection
$cb_TimedOutValue to assign to Callback_Timedout

Return value

SuccessReturns 1.  @extended = Main socket identifier.
FailureReturns 0 and set @error to:
  • 1 IPAddr is incorrect.
  • 2 port is incorrect.

@extended = windows API WSAGetError return value (see MSDN).

Disconnect

Disconnect from the server

Return value

SuccessReturns 1.
FailureReturns 0 and set @error = windows API WSAGetError return value (see MSDN).

IsConnected

Check if the client is connected to a server

Return value

Succes1 If connect, 0 If not connected

Send

Send data (Binary/String) to the server

Parameters

$s_bDataThe data to be sent (Binary/String)

Return value

SuccessReturns number of bytes sent to the server.
FailureReturns 0 and set @error = windows API WSAGetError return value (see MSDN).

Remark

If you want to send the ‘ char, you must send ‘’

Process

Function that calls all the client’s callbacks when events occures (Receiving, Lost connection...)

Remark

This method must be called in loop.

IP Adress of the server
Port number of the server
Receiving timeout (in ms).
Function that is called when data (Binary/String) is received from the server
Function that is called when being receiving data from the server
Function that is called when the connection with the server is lost.
Function that is called when a client is timed out
Close