Тема: WinSock API
Показать сообщение отдельно
  #2  
Старый 09.12.2010, 10:34
Аватар для NumLock
NumLock NumLock вне форума
Let Me Show You
 
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
По умолчанию

Цитата:
The Windows Sockets select function determines the status of one or more sockets, waiting if necessary.
int select (
int nfds,
fd_set FAR * readfds,
fd_set FAR * writefds,
fd_set FAR * exceptfds,
const struct timeval FAR * timeout
);

Parameters

nfds
[in] This argument is ignored and included only for the sake of compatibility.

readfds
[in/out] An optional pointer to a set of sockets to be checked for readability.

writefds
[in/out] An optional pointer to a set of sockets to be checked for writability

exceptfds
[in/out] An optional pointer to a set of sockets to be checked for errors.

timeout
[in] The maximum time for select to wait, or NULL for blocking operation.
что-то типа этого:
Код:
procedure check(ASocket: TSocket; ATimeOutWrite: Integer);
var
  ErrorCode: Integer;
  FDSet: TFDSet;
  TimeVal: TTimeVal;
begin
  if ASocket=INVALID_SOCKET then
    raise Exception.Create('invalid socket');
  FD_ZERO(FDSet);
  FD_SET(ASocket, FDSet);
  TimeVal.tv_sec:=ATimeOutWrite div 1000;
  TimeVal.tv_usec:=(ATimeOutWrite mod 1000)*1000;
  select(0, nil, @FDSet, nil, @TimeVal);
  if not FD_ISSET(ASocket, FDSet) then
    raise Exception.Create('exception');
end;
__________________
Пишу программы за еду.
__________________
Ответить с цитированием