Hi,
kann es sein das du keinen Zugriff auf dei Quell-
Unit 'ScktComp' hast?
Ein kleiner Auszug:
Delphi-Quellcode:
TAbstractSocket = class(TComponent)
private
FActive: Boolean;
FPort: Integer;
FAddress: string;
FHost: string;
FService: string;
procedure DoEvent(Sender: TObject; Socket: TCustomWinSocket; SocketEvent: TSocketEvent);
procedure DoError(Sender: TObject; Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer);
protected
procedure Event(Socket: TCustomWinSocket; SocketEvent: TSocketEvent); virtual; abstract;
procedure Error(Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; var ErrorCode: Integer); virtual; abstract;
procedure DoActivate(Value: Boolean); virtual; abstract;
procedure InitSocket(Socket: TCustomWinSocket);
procedure Loaded; override;
procedure SetActive(Value: Boolean);
procedure SetAddress(Value: string);
procedure SetHost(Value: string);
procedure SetPort(Value: Integer);
procedure SetService(Value: string);
property Active: Boolean read FActive write SetActive;
property Address: string read FAddress write SetAddress;
property Host: string read FHost write SetHost;
property Port: Integer read FPort write SetPort;
property Service: string read FService write SetService;
public
procedure Open;
procedure Close;
end;
TCustomSocket = class(TAbstractSocket)
private
FOnLookup: TSocketNotifyEvent;
FOnConnect: TSocketNotifyEvent;
FOnConnecting: TSocketNotifyEvent;
FOnDisconnect: TSocketNotifyEvent;
FOnListen: TSocketNotifyEvent;
FOnAccept: TSocketNotifyEvent;
FOnRead: TSocketNotifyEvent;
FOnWrite: TSocketNotifyEvent;
FOnError: TSocketErrorEvent;
protected
procedure Event(Socket: TCustomWinSocket; SocketEvent: TSocketEvent); override;
procedure Error(Socket: TCustomWinSocket; ErrorEvent: TErrorEvent;
var ErrorCode: Integer); override;
property OnLookup: TSocketNotifyEvent read FOnLookup write FOnLookup;
property OnConnecting: TSocketNotifyEvent read FOnConnecting write FOnConnecting;
property OnConnect: TSocketNotifyEvent read FOnConnect write FOnConnect;
property OnDisconnect: TSocketNotifyEvent read FOnDisconnect write FOnDisconnect;
property OnListen: TSocketNotifyEvent read FOnListen write FOnListen;
property OnAccept: TSocketNotifyEvent read FOnAccept write FOnAccept;
property OnRead: TSocketNotifyEvent read FOnRead write FOnRead;
property OnWrite: TSocketNotifyEvent read FOnWrite write FOnWrite;
property OnError: TSocketErrorEvent read FOnError write FOnError;
end;
TClientSocket = class(TCustomSocket)
private
FClientSocket: TClientWinSocket;
protected
procedure DoActivate(Value: Boolean); override;
function GetClientType: TClientType;
procedure SetClientType(Value: TClientType);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property Socket: TClientWinSocket read FClientSocket;
published
property Active;
property Address;
property ClientType: TClientType read GetClientType write SetClientType;
property Host;
property Port;
property Service;
property OnLookup;
property OnConnecting;
property OnConnect;
property OnDisconnect;
property OnRead;
property OnWrite;
property OnError;
end;
Wie du siehst, es gibt kein
Read welches als virtual deklariert ist.
Die einzige Komponente die hier eine Möglichkeit des Überschreibens einer Methode Read ermöglicht,
wäre
FClientSocket: TClientWinSocket -> TCustomWinSocket.Read(Socket: TSocket); virtual;.
Soll heißen, die Ableitung muss von ganz anderer Stelle aus erfolgen. Es müssen also neu geschrieben werden:
Delphi-Quellcode:
TNewCustomWinSocket =
class(TCustomWinSoket)
public
constructor Create(ASocket: TSocket);
override;
destructor Destroy;
override;
procedure Read(Socket: TSocket);
override;
property LocalHost;
property LocalAddress;
property LocalPort;
property RemoteHost;
property RemoteAddress;
property RemotePort;
property RemoteAddr;
property Connected;
property Addr;
property ASyncStyles;
property Handle;
property SocketHandle;
property LookupState;
property OnSocketEvent;
property OnErrorEvent;
property Data;
end;
TNewClientWinSocket =
class(TNewCustomWinSocket)
private
FClientType: TClientType;
protected
procedure SetClientType(Value: TClientType);
public
procedure Connect(Socket: TSocket);
override;
property ClientType: TClientType
read FClientType
write SetClientType;
end;
TClientSocket =
class(TCustomSocket)
private
FClientSocket: TNewClientWinSocket;
protected
procedure DoActivate(Value: Boolean);
override;
function GetClientType: TClientType;
procedure SetClientType(Value: TClientType);
public
constructor Create(AOwner: TComponent);
override;
destructor Destroy;
override;
property Socket: TClientWinSocket
read FClientSocket;
published
property Active;
property Address;
property ClientType: TClientType
read GetClientType
write SetClientType;
property Host;
property Port;
property Service;
property OnLookup;
property OnConnecting;
property OnConnect;
property OnDisconnect;
property OnRead;
property OnWrite;
property OnError;
end;
Und wie ich finde, ist das eine lösbare Aufgabe.
Viele Grüße