Back to product page

Receive method


Receives data from the user, as string expression.

Type

A String value. Contains received data.

Syntax

  • Basic
object.Receive ([ServiceIndex], [Count]) 
The Receive(object,ServiceIndex,Count) syntax has these parts:
objectAn expression evaluating to an object of type SSHUser.
ServiceIndexOptional. A Variant value. Index of the service you're receiving data from.
CountOptional. A Variant value. Maximum number of bytes you want to receive.

Remarks

Receive method will copy data from wodSSHD's internal buffers and pass it to string variable you can use in your code. Usually you will call this method as your response to Received event that was fired.

You should specify ServiceIndex argument to determine which service you will read data from. It only makes sense to read from service type stNone, because all others services are handled automatically by wodSSHD or external programs, so reading data from buffers could either return 0 characters (always), or interrupt above layer protocol and cause data corruption.

Usually you will not specify ServiceIndex because most users use only one service at a time - so default value 0 is used.

If you specify Count parameter then maximum of Count characters will be returned - or maximum of what wodSSHD receive from the client.

If you don't receive all available data, then Received event will be fired again (and again and again...) until all data is read, because leaving it in the buffer can produce memory problems with wodSSHD.

Usually you will try to respond to user entered commands, which end with CRLF (or CR on UNIX) sequences. Since Received event may be fired for each and every entered character, you might have to cache received data until CRLF occurs. You could use code like this for this purpose: (VB sample)
 
 
Private Sub SSHD1_Received(ByVal User As wodSSHDComLIB.ISSHUser, ByVal ServiceIndex As Long, ByVal BytesCount As Long)
Dim a As String
Dim i As Integer
  a = User.Receive
  User.Send a ' we need this so user can see what he entered (like echo)
  ReceivedData = ReceivedData + a
  i = InStr(1, ReceivedData, Chr$(13))
  If (i < 1) Then i = InStr(1, ReceivedData, Chr$(10))
  If i > 0 Then
........ rest of the code.....
 


Platforms

Windows