Click or drag to resize

CSocket.SendRaw Method

X#
Send any data to the connected socket.

Namespace:  VO
Assembly:  VOInternetClasses (in VOInternetClasses.dll) Version: 2.19
Syntax
 VIRTUAL METHOD SendRaw(
	pData AS PTR,
	nSize AS DWORD
) AS LOGIC
Request Example View Source

Parameters

pData
Type: Void*
Pointer to the data to be sent via the socket.
nSize
Type: DWord
Length of the data to be sent.

Return Value

Type: Logic
TRUE if successful; otherwise, FALSE.
Remarks
SendRaw() sends raw data to the connected socket.
Tip Tip
This method can be used for TCP sockets only, because it assumes that a connection is already established.
Examples
The following example demonstrates the use of this method:
X#
 1FUNCTION ClientTest2()  AS LOGIC PASCAL
 2LOCAL oSocket   AS CSocket
 3LOCAL cTo       AS STRING
 4LOCAL cData     AS STRING
 5LOCAL nSize     AS INT
 6LOCAL nPort     AS INT
 7CLS
 8oSocket  := CSocket{SOCK_STREAM}
 9IF oSocket:connect( HostName(), 7)
10  cData := MemoRead("Test.txt")
11  nSize := SLen(cData)
12  IF oSocket:SendRaw(PTR(_CAST, cData), nSize)
13  oSocket:GetPeerName(@cTo, @nPort)
14         ? "Data sent to ", cTo, ", port: ", ;
15          NTrim(nPort)
16  ENDIF
17ENDIF
18oSocket:Close()
19RETURN
See Also