Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Сети";
Текущий архив: 2003.03.10;
Скачать: [xml.tar.bz2];

Вниз

Как с помощью Indy компанент слать данные.   Найти похожие ветки 

 
allsamara   (2002-12-27 10:02) [0]

Как с помощью Indy компанент слать данные в реальном маштабе времени.
Я пробую с помощью компанент IdTCPClient и IdTCPServer.
Клиент:
var Streams:TMemoryStream;
....
Streams := TMemoryStream.Create();
Table1.SaveToStream(Streams);
Streams.Position := 0;

IdTCPClient1.WriteLn("Посылаю данные, принимай");
IdTCPClient1.OpenWriteBuffer;
try
IdTCPClient1.WriteStream(Streams);
finally
IdTCPClient1.CloseWriteBuffer;
Streams.Free;
end;


Сервер:
Streams := TMemoryStream.Create();
try
AThread.Connection.ReadStream(Streams);
Streams.Position := 0;
Table1.LoadFromStream(Streams);
finally
Streams.Free;
end;

Выдает иногда ошибку Out of memory, иногда: Socket error #0.


Что делаю не так?


 
NewGuest   (2002-12-27 10:10) [1]

В Demos пример есть...
Indy... Client/Server


 
allsamara   (2002-12-27 10:18) [2]

Я брал за основу пример из TCPStreamClientServer.
Но там происходит соединение, передача и дисконект.

А вот чтобы пересылать данные скажем через 10 сек на одном соединении. Этого не получается.

Может у меня руки кривые?


 
mrcat   (2003-01-22 23:35) [3]

procedure ReadStream(AStream: TStream; AByteCount: LongInt; const AReadUntilDisconnect: boolean);

AByteCount: LongInt = -1
Number of bytes to be read. Default value is -1.

const AReadUntilDisconnect: boolean = false
Indicates that data should be read from the protocol stack until disconnected. Default value is False.

AByteCount indicates the number of bytes to be read from the Indy buffer, or -1 if all bytes in the Indy buffer should be included. When AByteCount contains the number of bytes to be read, it is used to increase the size of AStream by the given number of bytes. This reduces memory or disk allocations to a single operation.

AReadUntilDisconnected indicates that data should be read from the protocol stack until the component is disconnected. When AReadUntilDisconnected is True, bytes are read from the protocol stack and written to AStream until Connected is False.

Note: When AByteCount is -1, and AReadUntilDisconnected is False, it is assumed that the first 4-bytes in the Indy buffer contains the length of buffered data in Internet format. ReadStream uses ReadInteger to convert the value to Intel byte-order prior to reading the remaining data from the Indy buffer.



procedure WriteStream(AStream: TStream; const AAll: boolean; const AWriteByteCount: Boolean); virtual;

const AAll: boolean = true
Write from the start of the stream. Default value is True.

const AWriteByteCount: Boolean = false

Write the stream sizew to the peer connection. Default value is False.

WriteStream is a procedure used to send the contents of the TStream descendant specified in AStream to the peer connection.
AAll indicates that the stream should be positioned to the stream origin prior to sending stream data.
AWriteByteCount indicates that the Integer value containing the size of the stream should be written to the peer connection prior to the stream data. When AAll is true, this value reflects the size of the entire stream. When AAll is False, this value indicates the stream sixe from the current stream position to the end of the stream.

When AWriteByteCount is True, WriteInteger is called to send the stream size to the peer connection.
WriteStream calls BeginWork with the work mode wmWrite and the size of the stream prior to sending stream data to the peer connection.
Stream data is sent to the peer in blocks, where each block can contain up to SendBufferSize bytes. Each block is read from the Indy buffer using ReadBuffer, and written to the peer connection using Write.


 
Selesty   (2003-01-22 23:49) [4]

Такой вопрос:
допустим у меня есть строка
ExeCode:string="x90xebx03x5dxebx05xe8xf8xffxffxffx83xc5x15x90x90"
@ExeCode - даст адрес этой строчки?
а как теперь засунуть этот адрес в eip чтобы код содержащийся в по этому адресу начал выполняться
И ещё в каком виде нужно загонять машинный код в строку, чтобы он выполнялся:
1 - в таком: a="\x90\xeb\x03\x5d\xeb\x05\xe8\xf8\xff\xff\xff\x83\xc5\x15\x90\x90"
2 - в таком:
a="x90xebx03x5dxebx05xe8xf8xffxffxffx83xc5x15x90x90"
3 - в таком:
a="90eb035deb05e8f8ffffff83c5159090"
Положит ли интерпритатор строку в стек, если я обозначу переменную содержащую маш коды как ExeCode:string="..." в Var функции (в модуле (unit))
как строка обозначенная как string будет расположена в 32 битном стеке, если строка будет представлять некий машинный код - выполнится ли он, если на него будет указывать eip?
Думаю вопрос понятен?!
Только не спрашивайте зачем мне это.... Просто Нуно очень
Ответ
2. Строку надо в виде:
SomeString: string=#$b0#$bf....;
3. вместо @SomeString используй procedure(PChar(SomeString))... так оно правильно адрес возьмет

procedure(PChar(SomeString)) - не совсем понятно, так как в регистр eip засунуть адрес строки, чтобы далее программа начала выполнять инструкции заданные машинными кодами в строке, допустим есть функция
function exe_code(var VerOS:byte); //VerOS - версия Оси (смотря какая)
var
SomeString:string=#$90#$eb#$03#$5d#$eb#$05#$e8#$f8#$ff#$ff#$ff#$83;
{Куда поместится эта строка?В стек или в data? - Важно - так как код самомодифицирующийся}
regi:registers;
P:Pchar;
begin
P:=@SomeString;
regi.ip:=p; //помещаем указатель на строку в eip - прокатит так?-начнёт ли код из //которого состоит SomeString выполняться?

end;
//Или как ещё можно заменить eip на нужный мне, в течение выполнения программы?



Страницы: 1 вся ветка

Форум: "Сети";
Текущий архив: 2003.03.10;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.46 MB
Время: 0.008 c
6-29995
Anton
2003-01-20 14:23
2003.03.10
Как можно отправить SMS сообщение из своей программы


7-30148
Dor
2003-01-10 10:15
2003.03.10
Image1-на рабочий стол


1-29794
Opera
2003-02-27 16:40
2003.03.10
Копирование


14-30116
Oleg_Em
2003-02-20 12:53
2003.03.10
Кто-нибудь работает с от InterSystems ?


14-30129
Killer2k
2003-02-23 17:04
2003.03.10
Please!!! Help me!!!





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский