Thanks for the quick response, I will try it under linux, once I got my vm working.
Maybe someone might find this useful, at least for windows:
unit UPipes;
interface
uses
Windows, Classes, SysUtils;
type
TPipeServer = class
private
FPipeHandle: THandle;
FPipeName: String;
FOverlapped: TOverlapped;
public
constructor Create(const APipename: string);
procedure Write(const ABuffer: PByte; const ASize: integer);
destructor Destroy; override;
end;
implementation
constructor TPipeServer.Create(const APipename: string);
var
sa: Security_Attributes;
sd: Security_Descriptor;
begin
FPipeName := '\\.\pipe\' + APipeName;
InitializeSecurityDescriptor(@sd,
SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(@sd, True, nil, False);
sa.nLength := SizeOf(sa);
sa.lpSecurityDescriptor := @sd;
sa.bInheritHandle := False;
FPipeHandle := CreateNamedPipe(PChar(FPipeName),
PIPE_ACCESS_OUTBOUND or FILE_FLAG_OVERLAPPED, PIPE_TYPE_BYTE,
1, 188 * 1024, 188 * 1024, 100, @sa);
fillchar(FOverlapped, sizeof(FOverlapped),0);
end;
destructor TPipeServer.Destroy;
begin
FlushFileBuffers(FPipeHandle);
DisconnectNamedPipe(FPipeHandle);
if FPipeHandle < INVALID_HANDLE_VALUE then
CloseHandle(FPipeHandle);
inherited;
end;
procedure TPipeServer.Write(const ABuffer: PByte; const ASize: integer);
var
BytesWritten: cardinal;
Dw: Cardinal;
begin
if not ConnectNamedPipe(FPipeHandle, @FOverlapped) then
begin
Dw := GetLastError;
if Dw <> ERROR_PIPE_CONNECTED then
begin
if Dw = ERROR_NO_DATA then
DisconnectNamedPipe(FPipeHandle);
exit;
end;
end;
BytesWritten := 0;
WriteFile(FPipeHandle, ABuffer^, ASize, BytesWritten, @FOverlapped);
end;
end.
Christian