[fpc-pascal] FIONREAD FPC FpIOCtl for Cross platform Sockets
Andrew Brunner
andrew.t.brunner at gmail.com
Wed Oct 7 18:42:33 CEST 2009
Sockets programming often requires a poll for how much data is
available on a particular socket descriptor.
I'm porting an inhouse library for a sockets implementation and I
realize that while I have a FpIOCtl call in the baseUnix unit I have
no such animal in the Sockets implement which would be cross platform.
Winsock does support this call and was wondering if someone wants to
just use the windows sockets implement in the Sockets unit instead of
using conditional definitions.
Windows Constants
FD_READ = $01;
FD_WRITE = $02;
FD_OOB = $04;
FD_ACCEPT = $08;
FD_CONNECT = $10;
FD_CLOSE = $20;
FD_QOS = $40;
FD_GROUP_QOS = $80;
FD_MAX_EVENTS = 8;
FD_ALL_EVENTS = $100; { AHS - trudno powiedzieæ, ile powinno byæ }
IOCPARM_MASK = $7f;
IOC_VOID = $20000000;
IOC_OUT = $40000000;
IOC_IN = $80000000;
IOC_INOUT = (IOC_IN or IOC_OUT);
FIONREAD = IOC_OUT or { get # bytes to read }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 127;
FIONBIO = IOC_IN or { set/clear non-blocking i/o }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 126;
FIOASYNC = IOC_IN or { set/clear async i/o }
((Longint(SizeOf(Longint)) and IOCPARM_MASK) shl 16) or
(Longint(Byte('f')) shl 8) or 125;
Winsock DLL calling for "ioctlsocket"
TWSF_ioctlsocket = function (s: TSocket; cmd: DWORD; var
arg: u_long): Integer; stdcall;
Anyone want to update the sockets unit to include a cross platform
ioctl function for sockets specifically?
Thanks a lot.
More information about the fpc-pascal
mailing list