The top-level object of the Client Socket UCX component. Used to connect to a server.
Gives the local address of the server.
Object.Address
String.
Read-only.
The address returned is based on the Protocol property setting. If Protocol is set to TCP, the IP address is returned. If Protocol is set to SPX, the IPX address is returned.
This example gives the local address of the server.
Set Cli=CreateObject("UCX:NWCliSkt")
Cli.Port = 80
Print "Address: " &cli.Address
Specifies the transfer mode of the data.
Object.Mode [=ModeConstant As Constant]
TransferMode.
Read/write.
ModeConstant is an optional parameter that can be set to either SYNC (0) or ASYNC (1). If set to ASYNC, the Send method returns immediately. Otherwise, it blocks the processor time until the data is actually transmitted.
This example sets the data transfer mode to Synchronous (SYNC).
Set cli=CreateObject("UCX:NWCliSkt")
cli.Protocol = TCP
cli.Port = 80
cli.Server = "IP:192.97.92.100"
cli.Mode = SYNC
Print "Mode: "&cli.Mode
Gives the server port number to be used for establishing a connection.
Object.Port [=PortNumber As Long]
Long.
Read/write.
PortNumber is an optional parameter that sets the server port number to be used for establishing a connection.
This example sets 80 as the port number to be used for establishing a connection with the server.
Set cli=CreateObject("UCX:NWCliSkt")
cli.Protocol = TCP
cli.Port = 80
Print "Port: " &cli.Port
Gives the protocol to be used to connect to the server.
Object.Protocol[=ProtocolConstant As Constant]
ProtocolConstant.
Read/write.
ProtocolConstant is an optional parameter that sets the protocol to be used to connect to the server. The default value for the protocol constant is TCP
See Protocol
Constants
.
This example sets the protocol to be used to connect to the server.
Set cli=CreateObject("UCX:NWCliSkt")
cli.Protocol = SPX
cli.Port = 80
Print "Protocol: " &cli.Protocol
Gives the server name or address.
Object.Server[=ServerNameAs String]
String.
Read/write.
ServerName is an optional parameter that sets the name of the server to be connected. It can be any of the following:
This example gives the server name or address.
Set cli=CreateObject("UCX:NWCliSkt")
cli.Protocol = TCP
cli.Port = 80
cli.Server = "IP:192.97.92.100"
Print "Server: " &cli.Server
A Bindery object type for the service that is advertised using Service Advertising Protocol (SAP).
Object.ServiceType[=ServiceType As Long]
Long.
Read/write.
ServiceType is an optional parameter that sets the type of service to be connected.
This example sets the data transfer mode to Synchronous (SYNC).
Set cli=CreateObject("UCX:NWCliSkt")
cli.Protocol = TCP
cli.Port = 80
cli.Server = "IP:192.97.92.100"
cli.Mode = SYNC
cli.ServiceType = 1200
Print "Service Type: "&cli.ServiceType
Specifies the timeout value in milliseconds.
object.TimeOut [=TimeOut As Long]
Long.
Read/write.
TimeOut is an optional parameter that sets the time, in milliseconds, for the timeout operation.
This property is applicable to any SPX protocol. The default value is 5000.
This example sets the timeout value at 6000 milliseconds.
set cli=CreateObject("UCX:NWCliSkt")
cli.Protocol = TCP
cli.Port = 80
cli.Server = "IP:192.97.92.100"
cli.TimeOut = 6000
Print "TimeOut: " &cli.TimeOut
Establishes a connection to the server.
Object.Connect()
None.
Boolean. Returns TRUE if the connection is established successfully; otherwise, FALSE.
The Connected event is fired after the connection is established.
This example establishes a connection with the server.
Set cli=CreateObject("UCX:NWCliSkt")
cli.Port = 80
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
cli.TimeOut = 10000
cli.Protocol = TCP
If(cli.Connect() = True) Then
Print("Connection Successful")
Else
Print("Connection Failed")
End If
cli.Disconnect()
Disconnects the connection.
object.Disconnect()
None.
Boolean. Returns TRUE if the server is disconnected successfully. Else returns FALSE.
This example disconnects from the server.
set cli=CreateObject("UCX:NWCliSkt")
cli.Port = 80
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
cli.TimeOut = 10000
cli.Protocol = TCP
cli.Connect()
If(cli.Disconnect() = TRUE) Then
Print("Disconnected Successfully")
Else
Print("Unable to disconnect")
End If
Transfers data from the connected server.
object.Send(
Data As Variant)
Boolean. Returns TRUE if the data is sent successfully. Else returns FALSE.
This example sends the text "My Data" across the established connection.
Set cli=CreateObject("UCX:NWCliSkt")
cli.Port = 7
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
If(cli.Connect()) Then
If(cli.Send("My Data")) Then
Print("Data is sent successfully")
End If
End If
cli.Disconnect()
Fires on a successful connection.
sub object_Connected()
None.
None.
This example fires the connected event and executes a sub routine to print a message, when the server is connected successfully.
Set cli=CreateObject("UCX:NWCliSkt")
cli.Port = 80
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
If(cli.Connect() = True) Then
Print("Connection Successful")
Else
Print("Connection Failed")
End If
cli.Disconnect()
sub cli_Connected()
Print "Connected to the server"
End sub
Fired once the connection is disconnected.
sub object_Disconnected()
None.
None.
This example fires the connected event and executes a sub routine to print a message, when the server is disconnected successfully.
set cli=CreateObject("UCX:NWCliSkt")
cli.Port = 80
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
cli.Protocol = TCP
cli.Connect()
If(cli.Disconnect()) Then
Print("Disconnect Successful")
Else
Print("Disconnect Failed")
End If
Sub cli.Disconnected()
Print "Disconnected from the server"
End sub
Fired for socket-related errors.
sub object_Error(
Number As Integer,
Description As String)
None.
This example fires for socket-related errors. In this case, the error is an invalid port number.
set cli=CreateObject("UCX:NWCliSkt")
’Bad port number is given to cause Error event
cli.Port = 74545
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
cli.Protocol = TCP
If(cli.Connect()) Then
Print("connected successfully")
End If
cli.Disconnect()
Sub cli_Error(Err_Number, Err_Description)
Print "The error is " &Err_Number
Print "Description is: " &Err_Description)
End Sub
Fired when the data from the server is received by the client.
sub object_Receive(
Data As String)
None.
This example fires the receive event, when the data from the server is received by the client, successfully.
set cli=CreateObject("UCX:NWCliSkt")
cli.Port = 7
cli.Server = "IP:193.97.92.100"
cli.Mode = SYNC
cli.Protocol = TCP
If(cli.Connect() = TRUE) Then
If(cli.Send("My Data") = True) Then
Print("Data is sent successfully")
End If
End If
cli.Disconnect()
Sub cli_Receive(Data)
Print "Receive event is fired"
Print("Received data is: " &Data)
End Sub