Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2003.08.25;
Скачать: 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 вся ветка

Текущий архив: 2003.08.25;
Скачать: CL | DM;

Наверх




Память: 0.47 MB
Время: 0.022 c
3-81573
Владий
2003-07-31 09:52
2003.08.25
Как сделать запрос?...


1-81782
iNew
2003-08-14 05:10
2003.08.25
Автоматическое копирование файлов.


1-81780
lightix
2003-08-14 11:03
2003.08.25
Из даты узнать наименование месяца, дня недели и т.п.


14-81923
Карелин Артем
2003-08-07 11:25
2003.08.25
Почему аська при каждом коннекте лезет на web-сервак?


14-81921
RV_Raven
2003-07-28 20:49
2003.08.25
Можно ли с помощью Delphi отловить опасный HTML код до того как