Вниз
Скачать: CL | DM;

Обработка событий WInSock   Найти похожие ветки 

← →
GreatLesh   (2003-06-19 07:55) [0]

Как узнать, что произошел disconnect с другой стороны?


← →
Digitman ©   (2003-06-19 08:09) [1]

именно в WinsockAPI ?


← →
panov ©   (2003-06-19 10:41) [2]

Вот так, например:

function TThSC.fWaitEvent(aTimeOut:Cardinal): Cardinal;
var
wne: WSANETWORKEVENTS;
begin
WSAResetEvent(fEvent);
WaitForSingleObject(fEvent,aTimeOut);
WSAEnumNetworkEvents(fSocket,fEvent,@wne);
Result := wne.lNetworkEvents;
Exit;
end;

procedure TThSC.Execute;
var
WaitResult: Cardinal;
begin
repeat
WaitResult := fWaitEvent(1);

if WaitResult=WSA_WAIT_FAILED then Terminate;
if WaitResult=WSA_WAIT_TIMEOUT then continue;
if Terminated then Exit;

if (WaitResult and FD_READ)=FD_READ then
begin
onReceive;
end;
if (WaitResult and FD_CLOSE)=FD_CLOSE then
begin
OnClosed;
Terminate;
break;
end;
if (WaitResult and FD_WRITE)=FD_WRITE then
begin
OnWrite;
( WaitResult = WAIT_FAILED) Вот так, например:

function TThSC.fWaitEvent(aTimeOut:Cardinal): Cardinal;
var
wne: WSANETWORKEVENTS;
begin
WSAResetEvent(fEvent);
WaitForSingleObject(fEvent,aTimeOut);
WSAEnumNetworkEvents(fSocket,fEvent,@wne);
Result := wne.lNetworkEvents;
Exit;
end;

procedure TThSC.Execute;
var
WaitResult: Cardinal;
begin
repeat
WaitResult := fWaitEvent(1);

if WaitResult=WSA_WAIT_FAILED then Terminate;
if WaitResult=WSA_WAIT_TIMEOUT then continue;
if Terminated then Exit;

if (WaitResult and FD_READ)=FD_READ then
begin
onReceive;
end;
if (WaitResult and FD_CLOSE)=FD_CLOSE then
begin
OnClosed;
Terminate;
break;
end;
if (WaitResult and FD_WRITE)=FD_WRITE then
begin
OnWrite;
end;

until (WaitResult = WAIT_FAILED) or Terminated;
end;



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

Скачать: CL | DM;



Память: 0.45 MB
Время: 0.022 c
14-81926
Yanis
2003-08-07 02:51
2003.08.25
Где взять статьи по 3D Max в инете?


1-81622
Васька
2003-08-12 23:03
2003.08.25
TaskBar


1-81732
Mishenka
2003-08-07 15:53
2003.08.25
Запись информации.


1-81763
GrBob
2003-08-15 12:19
2003.08.25
Form1.Canvas.Draw


1-81645
Juliet
2003-08-12 12:58
2003.08.25
Toolbar-ы




   Наверх