Send

Send is used to send data to the current open socket over a TCP connection.

Syntax

Send (data, [SizeInBytes])

Returns

The actual amount of sent bytes.

More Information

The Send function can only be used with an open Socket Object that was opened on a TCP connect. To Send data over a UDP Connection see the SendTo function further on in the document.

The Send function accepts an optional parameter (SizeInBytes) which specifies how much of the buffer which was passed to the data field will actually be sent. If this optional parameter is omitted, then the size is automatically calculated.

Example

This Script displays the default page in raw html of a web server running locally. The script can be made to work with any web server by simply changing the value of the variable "ip":

Function Main

Dim SocketObject As Object

Dim ip As String

Dim port As String

Dim req As String

Dim strResponse As String

Ip = "172.16.130.112"

Port = "80"

req = "GET / HTTP/1.0"

'carriage return and line feed

cr = Chr(13) + Chr(10)

req = CStr(req +cr +cr)

Socket.SetTimeout 5000,5000

Set SocketObject = Socket.OpenTcp(Ip,Port)

'check to see that the Object returned successfully

If Not SocketObject is Nothing Then

SocketObject.Send(CStr(req))

strResponse = SocketObject.Recv(1024)

While Len(CStr(strResponse)) <> 0

echo(strResponse)

StrResponse = SocketObject.Recv(1024)

Wend

echo(strResponse)

End If

End Function