![]() |
Duda con TStream.Readbuffer
Hola a todos si alguien pudiera ayudarme con una duda que tengo me resolveria un gran problema, el asunto es que estoy haciendo un broadcast con los componentes UDP de los Indy, hasta ahi todo bien, el problema es cuando intento leer los datos, es un hecho que llega el mensaje a todas las maquinas de la red pues se dispara el evento de que llego un mensaje, bien pero el problema es que el parametro del evento que contiene los datos es un TStream, este tiene un metodo que se llama readbuffer el problema es que no se como utilizar este metodo y no puedo obtener la informacion???':confused:
espero haya podido quedar un poco claro si no entienen por favor diganmelo a ver si puedo intentar aclarar un poco esto disculpen la molestia salu2 miguel_e |
TStream.WriteBuffer/ReadBuffer
Esta respuesta la da Peter Below de los TeamB a un usuario....no se si está permitido poner este tipo de mensajes
pero como soy nuevo lo pongo y si alguien tiene algo que decir que lo diga, que lo borre y todos contentos y felices :) In article <3f7fbccf@newsgroups.borland.com>, Bob McKinnon wrote: > I would like to write out an array of long strings along with other data to > a file. I tried to create a file records like I normally do but that did > not work since I was using a string. I wonder if streams is the way to go? > To make it simple, if I have a data object that contains two integers and > an array of strings it easy to stream that out to file? Sample code would > be great. > > Test = class (Tobject) > x, x1 : Integer; > StList : array [1..100] of string; > End; Since strings are variable-length data you need to write the length of a string in addition to the characters to the stream, otherwise you cannot read them back conveniently. Lets add two methods to your Test class: Since ReadBuffer and WriteBuffer use untyped parameters handing them an Ansistring (which is a pointer type) is a bit unintuitive: you have to pass the first character of the string to get the correct address across. -- Peter Below (TeamB) |
Hola, muchas gracias por tu repuesta, ya le di solucion al problema así
salu2 miguel_e Código:
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream; |
La franja horaria es GMT +2. Ahora son las 04:22:55. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi