Board index » delphi » How to send dynamic Byte array

How to send dynamic Byte array

Hi.
I use TClientSocket and TClientWinSocket to send a dynamic byte array to
server by TClientWinSocket.SendBuf. But the only Address of dynamic byte
array is sent.Why?
How can I do? Please give me  example code.

very thanks
cms
2000-11-8

 

Re:How to send dynamic Byte array


An Array in Delphi is a pointer to memory. You probably send the array (=
the pointer to the memory). To send the data of this array, try
 "MyArray^" intead of "MyArray".
The problem with Delphi is, that it interpreteds what you mean, pointer or
data.
For normal functions and procedures, sending a pointer is faster then
sending the complete data.
That's why Delphi standard sends just the pointer.
If you use "^", you tell Delphi to pass the data instead of the pointer.
I dont know about the SendBuf function if it will take this parameter, but
give it a try.

Herman.

Quote
"cms" <xqlmzlh...@sina.com.cn> wrote in message

news:8ub2gj$r8o7@bornews.inprise.com...
Quote
> Hi.
> I use TClientSocket and TClientWinSocket to send a dynamic byte array to
> server by TClientWinSocket.SendBuf. But the only Address of dynamic byte
> array is sent.Why?
> How can I do? Please give me  example code.

> very thanks
> cms
> 2000-11-8

Re:How to send dynamic Byte array


Instead of using Send...(...,arrayname,arraysize,...) use
Send...(...,arrayname[0],arraysize,...);

(of course make sure that the array has at least one element :)

johannes
--
Please reply in this newsgroup only
 - SIP solutions -
http://www.sipsolutions.de/

Other Threads