- baseunix,unix,unixutil,\r
+ baseunix,unix,unixutil,sockets,\r
TSendData = procedure (Sender: TObject; BytesSent: Integer) of object;\r
\r
tlcomponent = class(tcomponent)\r
TSendData = procedure (Sender: TObject; BytesSent: Integer) of object;\r
\r
tlcomponent = class(tcomponent)\r
onsenddata : tsenddata ;\r
ondatasent : tsocketevent ;\r
//connected : boolean ;\r
onsenddata : tsenddata ;\r
ondatasent : tsocketevent ;\r
//connected : boolean ;\r
- procedure sendstr(const str : string);virtual;\r
- procedure putstringinsendbuffer(const newstring : string);\r
+ procedure sendstr(const str : tbufferstring);virtual;\r
+ procedure putstringinsendbuffer(const newstring : tbufferstring);\r
function send(data:pointer;len:integer):integer;virtual;\r
procedure putdatainsendbuffer(data:pointer;len:integer); virtual;\r
procedure deletebuffereddata;\r
function send(data:pointer;len:integer):integer;virtual;\r
procedure putdatainsendbuffer(data:pointer;len:integer); virtual;\r
procedure deletebuffereddata;\r
- procedure myfdclose(fd : integer); virtual;{$ifdef win32}abstract;{$endif}\r
- function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; virtual;{$ifdef win32}abstract;{$endif}\r
- function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; virtual;{$ifdef win32}abstract;{$endif}\r
+ procedure myfdclose(fd : integer); virtual;{$ifdef mswindows}abstract;{$endif}\r
+ function myfdwrite(fd: LongInt;const buf;size: LongInt):LongInt; virtual;{$ifdef mswindows}abstract;{$endif}\r
+ function myfdread(fd: LongInt;var buf;size: LongInt):LongInt; virtual;{$ifdef mswindows}abstract;{$endif}\r
fontimer : tnotifyevent ;\r
fenabled : boolean ;\r
finterval : integer ; {miliseconds, default 1000}\r
fontimer : tnotifyevent ;\r
fenabled : boolean ;\r
finterval : integer ; {miliseconds, default 1000}\r
- {$ifdef win32}\r
- windows.sleep(i);\r
- {$else}\r
- tv.tv_sec := i div 1000;\r
- tv.tv_usec := (i mod 1000) * 1000;\r
- select(0,nil,nil,nil,@tv);\r
- {$endif}\r
+ tv.tv_sec := i div 1000;\r
+ tv.tv_usec := (i mod 1000) * 1000;\r
+ select(0,nil,nil,nil,@tv);\r
+{$endif}\r
- if prevasin <> nil then begin\r
- prevasin.nextasin := nextasin;\r
- end else begin\r
- firstasin := nextasin;\r
- end;\r
- if nextasin <> nil then begin\r
- nextasin.prevasin := prevasin;\r
- end;\r
procedure tlasio.internalclose(error:word);\r
begin\r
if (state<>wsclosed) and (state<>wsinvalidstate) then begin\r
procedure tlasio.internalclose(error:word);\r
begin\r
if (state<>wsclosed) and (state<>wsinvalidstate) then begin\r
if (fdhandlein < 0) or (fdhandleout < 0) then raise exception.create('internalclose called with invalid fd handles');\r
eventcore.rmasterclr(fdhandlein);//fd_clr(fdhandlein,fdsrmaster);\r
eventcore.wmasterclr(fdhandleout);//fd_clr(fdhandleout,fdswmaster);\r
\r
if closehandles then begin\r
if (fdhandlein < 0) or (fdhandleout < 0) then raise exception.create('internalclose called with invalid fd handles');\r
eventcore.rmasterclr(fdhandlein);//fd_clr(fdhandlein,fdsrmaster);\r
eventcore.wmasterclr(fdhandleout);//fd_clr(fdhandleout,fdswmaster);\r
\r
if closehandles then begin\r
//anyone remember why this is here? --plugwash\r
fcntl(fdhandlein,F_SETFL,0);\r
{$endif}\r
myfdclose(fdhandlein);\r
if fdhandleout <> fdhandlein then begin\r
//anyone remember why this is here? --plugwash\r
fcntl(fdhandlein,F_SETFL,0);\r
{$endif}\r
myfdclose(fdhandlein);\r
if fdhandleout <> fdhandlein then begin\r
fcntl(fdhandleout,F_SETFL,0);\r
{$endif}\r
myfdclose(fdhandleout);\r
fcntl(fdhandleout,F_SETFL,0);\r
{$endif}\r
myfdclose(fdhandleout);\r
\r
lensent := sendq.get(data,packetbasesize*2);\r
if assigned(data) then result := myfdwrite(fdhandleout,data^,lensent) else result := 0;\r
\r
lensent := sendq.get(data,packetbasesize*2);\r
if assigned(data) then result := myfdwrite(fdhandleout,data^,lensent) else result := 0;\r
fdhandlein := invalue;\r
fdhandleout := invalue;\r
eventcore.setfdreverse(fdhandlein,self);\r
fdhandlein := invalue;\r
fdhandleout := invalue;\r
eventcore.setfdreverse(fdhandlein,self);\r
- {$ifdef win32}
- if getlasterror=WSAEWOULDBLOCK then begin
- //the asynchronous nature of windows messages means we sometimes
- //get here with the buffer full
- //so do nothing in that case
- end else
- {$endif}
- begin
- internalclose({$ifdef win32}getlasterror{$else}linuxerror{$endif});\r
- end
+ {$ifdef mswindows}\r
+ if getlasterror=WSAEWOULDBLOCK then begin\r
+ //the asynchronous nature of windows messages means we sometimes\r
+ //get here with the buffer full\r
+ //so do nothing in that case\r
+ end else\r
+ {$endif}\r
+ begin\r
+ internalclose({$ifdef mswindows}getlasterror{$else}linuxerror{$endif});\r
+ end \r
//sometimes on windows we get stale messages due to the inherent delays\r
//in the windows message queue\r
if WSAGetLastError = wsaewouldblock then begin\r
//sometimes on windows we get stale messages due to the inherent delays\r
//in the windows message queue\r
if WSAGetLastError = wsaewouldblock then begin\r
if assigned(timerwrapperinterface) then begin\r
timerwrapperinterface.setenabled(wrappedtimer,newvalue);\r
end else begin\r
if assigned(timerwrapperinterface) then begin\r
timerwrapperinterface.setenabled(wrappedtimer,newvalue);\r
end else begin\r
if assigned(timerwrapperinterface) then begin\r
timerwrapperinterface.setinterval(wrappedtimer,newvalue);\r
end else begin\r
if assigned(timerwrapperinterface) then begin\r
timerwrapperinterface.setinterval(wrappedtimer,newvalue);\r
end else begin\r
if (result > 0) and assigned(onsenddata) then onsenddata(self,result);\r
eventcore.wmasterset(fdhandleout);\r
end;\r
if (result > 0) and assigned(onsenddata) then onsenddata(self,result);\r
eventcore.wmasterset(fdhandleout);\r
end;\r