各位大侠,小弟最近做一个Midas三层服务器,遇到不少问题,查看了以前的帖子,仍没有解决,还请大家帮忙解决,我分只有这么多,真不好意思,问题如下:
1、压缩
我知道用intrcpt.dll注册可能解决,但我想把它和Scktsrvr接合在一起,在服务端与客户端不需要注册就可以实现,请问怎么解决运用,即怎么样在Scktsrvr中调用DataIn和DataOut,因为我没有做成Com+,所以想直接接合在一起。
2、加密
怎么把加密也接合在Scktsrvr中。
3、什么好方法能解决超时的问题。
4、Scktsrvr中的ClientExecute过程怎么修改达到最好,ClientExecute源码如下,请帮忙。
procedure TSocketDispatcherThread.ClientExecute;
var
Data: IDataBlock;
msg: TMsg;
Obj: ISendDataBlock;
Event: THandle;
WaitTime: DWord;
begin
CoInitialize(nil);
try
Synchronize(AddClient);
FTransport := CreateServerTransport;
try
Event := FTransport.GetWaitEvent;
PeekMessage(msg, 0, WM_USER, WM_USER, PM_NOREMOVE);
GetInterface(ISendDataBlock, Obj);
if FRegisteredOnly then
FInterpreter := TDataBlockInterpreter.Create(Obj, SSockets) else
FInterpreter := TDataBlockInterpreter.Create(Obj, '');
try
Obj := nil;
if FTimeout = 0 then
WaitTime := INFINITE else
WaitTime := 60000;
while not Terminated and FTransport.Connected do
try
case MsgWaitForMultipleObjects(1, Event, False, WaitTime, QS_ALLEVENTS) of
WAIT_OBJECT_0:
begin
WSAResetEvent(Event);
Data := FTransport.Receive(False, 0);
if Assigned(Data) then
begin
FLastActivity := Now;
FInterpreter.InterpretData(Data);
Data := nil;
FLastActivity := Now;
end;
end;
WAIT_OBJECT_0 + 1:
while PeekMessage(msg, 0, 0, 0, PM_REMOVE) do
DispatchMessage(msg);
WAIT_TIMEOUT:
if (FTimeout > 0) and ((Now - FLastActivity) > FTimeout) then
FTransport.Connected := False;
end;
except
FTransport.Connected := False;
end;
finally
FInterpreter.Free;
FInterpreter := nil;
end;
finally
FTransport := nil;
end;
finally
CoUninitialize;
Synchronize(RemoveClient);
end;
end;
1、压缩
我知道用intrcpt.dll注册可能解决,但我想把它和Scktsrvr接合在一起,在服务端与客户端不需要注册就可以实现,请问怎么解决运用,即怎么样在Scktsrvr中调用DataIn和DataOut,因为我没有做成Com+,所以想直接接合在一起。
2、加密
怎么把加密也接合在Scktsrvr中。
3、什么好方法能解决超时的问题。
4、Scktsrvr中的ClientExecute过程怎么修改达到最好,ClientExecute源码如下,请帮忙。
procedure TSocketDispatcherThread.ClientExecute;
var
Data: IDataBlock;
msg: TMsg;
Obj: ISendDataBlock;
Event: THandle;
WaitTime: DWord;
begin
CoInitialize(nil);
try
Synchronize(AddClient);
FTransport := CreateServerTransport;
try
Event := FTransport.GetWaitEvent;
PeekMessage(msg, 0, WM_USER, WM_USER, PM_NOREMOVE);
GetInterface(ISendDataBlock, Obj);
if FRegisteredOnly then
FInterpreter := TDataBlockInterpreter.Create(Obj, SSockets) else
FInterpreter := TDataBlockInterpreter.Create(Obj, '');
try
Obj := nil;
if FTimeout = 0 then
WaitTime := INFINITE else
WaitTime := 60000;
while not Terminated and FTransport.Connected do
try
case MsgWaitForMultipleObjects(1, Event, False, WaitTime, QS_ALLEVENTS) of
WAIT_OBJECT_0:
begin
WSAResetEvent(Event);
Data := FTransport.Receive(False, 0);
if Assigned(Data) then
begin
FLastActivity := Now;
FInterpreter.InterpretData(Data);
Data := nil;
FLastActivity := Now;
end;
end;
WAIT_OBJECT_0 + 1:
while PeekMessage(msg, 0, 0, 0, PM_REMOVE) do
DispatchMessage(msg);
WAIT_TIMEOUT:
if (FTimeout > 0) and ((Now - FLastActivity) > FTimeout) then
FTransport.Connected := False;
end;
except
FTransport.Connected := False;
end;
finally
FInterpreter.Free;
FInterpreter := nil;
end;
finally
FTransport := nil;
end;
finally
CoUninitialize;
Synchronize(RemoveClient);
end;
end;
thanks Your Answer。我也知道有啊,加密算法也知道,可不知道怎么加进去,做成Dll是没问题,可要注册,太麻烦了,我用的是midas,想只接写进去,而不用注册,能详细一点吗?
function TSocketTransport.CheckInterceptor: Boolean;
var
GUID: TGUID;
begin
if not Assigned(FInterceptor) and (FInterceptGUID <> '') then
if not FCreateAttempted then
try
FCreateAttempted := True;
Guid := StringToGuid(FInterceptGUID);
FInterceptor := CreateComObject(Guid) as IDataIntercept;
except
{ raise no exception if the creating failed }
end;
Result := Assigned(FInterceptor);
end;比如改成:
//===========================================================
function TSocketTransport.CheckInterceptor: Boolean;
var
GUID: TGUID;
begin
if not Assigned(FInterceptor) then
try
FInterceptor:=CreateMyInterceptor;
except
{ raise no exception if the creating failed }
end;
Result := Assigned(FInterceptor);
end;function CreateMyInterceptor:IInterceptor;
begin
Result:=TMyInterceptor.Create;
end;TMyInterceptor=class(TInterfacedObject,IInterceptor)
....
end;