10.5 Connection Object

Provides information about a single client connection.

10.5.1 Address property

Gives the client address.

Syntax

object.Address()

Type

String.

Attributes

Read-only.

Example

This example gives the client address.

’Usage: Run this sample, make client connections 
’Send welcome message to all clients 
Sub srvskt_conn 
     set connsrv=CreateObject("UCX:NWSrvSkt") 
     connsrv.Port = 8080 
     connsrv.Protocol = TCP 
     connsrv.Listen = True 
     ’Wait in infinite loop for client connections 
     print "Listening for client connections "
     Set cs = csrstsrv.Clients 
     while true 
     Wend 
End Sub 
 
Sub connsrv_connect(conn) 
     Print "A new connection from: " 
     Print Conn.Address &" : " & Conn.port 
     ’Send welcome message 
     conn.Send ("Welcome to NSN Socket Services") 
End Sub

See Also

10.5.2 Port property

Gives the client port number.

Syntax

object.Port()

Type

Long.

Attributes

Read-only.

Example

This example gives the client port number.

’Usage: Run this sample, make client connections 
’Send welcome message to all clients 
Sub srvskt_conn 
  set connsrv=CreateObject("UCX:NWSrvSkt") 
 connsrv.Port = 8080 
 connsrv.Protocol = TCP 
 connsrv.Listen = True 
 ’Wait in infinite loop for client connections 
 Print "Listening for client connections "
 Set cs = csrstsrv.Clients 
 while true 
 Wend 
End Sub 
 
Sub connsrv_connect(conn) 
 Print "A new connection from: " 
 Print Conn.Address &" : " & Conn.port 
 ’Send welcome message 
 conn.Send ("Welcome to NSN Socket Services") 
End Sub

See Also

10.5.3 Send method

Sends data to the client identified by this connection.

Syntax

object.Send( 
   Data As Variant)

Parameters

Data

Any type of data (such as a string of text).

Return Values

Boolean. Returns TRUE if the data is sent; otherwise, FALSE.

Example

This example sends the message "Welcome to NSN Socket Services" to the client identified by this collection.

’Usage: Run this sample, make client connections 
’Send welcome message to all clients 
Sub srvskt_conn 
  set connsrv=CreateObject("UCX:NWSrvSkt") 
  connsrv.Port = 8080 
  connsrv.Protocol = TCP 
  connsrv.Listen = True 
  ’Wait in infinite loop for client connections 
  Print "Listening for client connections "
  Set cs = csrstsrv.Clients 
  while true 
  Wend 
End Sub 
 
Sub connsrv_connect(conn) 
  Print "A new connection from: " 
  Print Conn.Address &" : " & Conn.port 
  ’Send welcome message 
  conn.Send ("Welcome to NSN Socket Services") 
End Sub

See Also