/[lcore]/trunk/lsocket.pas
ViewVC logotype

Diff of /trunk/lsocket.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 75 by plugwash, Fri Feb 12 22:16:05 2010 UTC revision 79 by zipplet, Tue Feb 16 22:51:30 2010 UTC
# Line 94  Line 94 
94        //host               : THostentry      ;        //host               : THostentry      ;
95    
96        //mainthread         : boolean         ; //for debuggin only        //mainthread         : boolean         ; //for debuggin only
97        addr:string;        addr:thostname;
98        port:string;        port:ansistring;
99        localaddr:string;        localaddr:thostname;
100        localport:string;        localport:ansistring;
101        proto:string;        proto:ansistring;
102        udp,dgram:boolean;        udp,dgram:boolean;
103        listenqueue:integer;        listenqueue:integer;
104        {$ifdef secondlistener}        {$ifdef secondlistener}
# Line 118  Line 118 
118    
119        procedure handlefdtrigger(readtrigger,writetrigger:boolean); override;        procedure handlefdtrigger(readtrigger,writetrigger:boolean); override;
120        function send(data:pointer;len:integer):integer;override;        function send(data:pointer;len:integer):integer;override;
121        procedure sendstr(const str : string);override;        procedure sendstr(const str : tbufferstring);override;
122        function Receive(Buf:Pointer;BufSize:integer):integer; override;        function Receive(Buf:Pointer;BufSize:integer):integer; override;
123        function getpeername(var addr:tsockaddrin;addrlen:integer):integer; virtual;        function getpeername(var addr:tsockaddrin;addrlen:integer):integer; virtual;
124        procedure getXaddrbin(var binip:tbinip); virtual;        procedure getXaddrbin(var binip:tbinip); virtual;
125        procedure getpeeraddrbin(var binip:tbinip); virtual;        procedure getpeeraddrbin(var binip:tbinip); virtual;
126        function getXaddr:string; virtual;        function getXaddr:thostname; virtual;
127        function getpeeraddr:string; virtual;        function getpeeraddr:thostname; virtual;
128        function getXport:string; virtual;        function getXport:ansistring; virtual;
129        function getpeerport:string; virtual;        function getpeerport:ansistring; virtual;
130        constructor Create(AOwner: TComponent); override;        constructor Create(AOwner: TComponent); override;
131    
132        //this one has to be kept public for now because lcorewsaasyncselect calls it        //this one has to be kept public for now because lcorewsaasyncselect calls it
133        procedure connectionfailedhandler(error:word);        procedure connectionfailedhandler(error:word);
134      private      private
135          {$ifdef ipv6}
136        isv6socket : boolean; //identifies if the socket is v6, set by bindsocket        isv6socket : boolean; //identifies if the socket is v6, set by bindsocket
137          {$endif}
138        procedure taskcallconnectionfailedhandler(wparam,lparam : longint);        procedure taskcallconnectionfailedhandler(wparam,lparam : longint);
139    
140        procedure connecttimeouthandler(sender:tobject);        procedure connecttimeouthandler(sender:tobject);
# Line 297  Line 299 
299    realconnect;    realconnect;
300  end;  end;
301    
302  procedure tlsocket.sendstr(const str : string);  procedure tlsocket.sendstr(const str : tbufferstring);
303  begin  begin
304    if dgram then begin    if dgram then begin
305      send(@str[1],length(str))      send(@str[1],length(str))
# Line 352  Line 354 
354        end;        end;
355        //gethostbyname(localaddr,host);        //gethostbyname(localaddr,host);
356        inaddrtempsize := makeinaddrv(forwardlookup(localaddr,0),localport,inaddrtemp);        inaddrtempsize := makeinaddrv(forwardlookup(localaddr,0),localport,inaddrtemp);
357          {$ifdef ipv6}
358        isv6socket := (inaddrtemp.inaddr.family = AF_INET6);        isv6socket := (inaddrtemp.inaddr.family = AF_INET6);
359          {$endif}
360        If Bind(fdhandlein,inaddrtempx,inaddrtempsize)<> {$ifdef win32}0{$else}true{$endif} Then begin        If Bind(fdhandlein,inaddrtempx,inaddrtempsize)<> {$ifdef win32}0{$else}true{$endif} Then begin
361          state := wsclosed;          state := wsclosed;
362          lasterror := {$ifdef win32}getlasterror{$else}socketerror{$endif};          lasterror := {$ifdef win32}getlasterror{$else}socketerror{$endif};
# Line 373  Line 377 
377    yes,no:longint;    yes,no:longint;
378    socktype:integer;    socktype:integer;
379    biniptemp:tbinip;    biniptemp:tbinip;
380    origaddr:string;    origaddr:thostname;
381  begin  begin
382    if state <> wsclosed then close;    if state <> wsclosed then close;
383    udp := uppercase(proto) = 'UDP';    udp := uppercase(proto) = 'UDP';
# Line 405  Line 409 
409    fdhandlein := socket(biniptemp.family,socktype,0);    fdhandlein := socket(biniptemp.family,socktype,0);
410    {$ifdef ipv6}    {$ifdef ipv6}
411    if (addr = '::') and (origaddr = '') and (fdhandlein < 0) then begin    if (addr = '::') and (origaddr = '') and (fdhandlein < 0) then begin
412      writeln('failed to create an IPV6 socket with error ',socketerror,'. trying to create an IPV4 one instead');      {writeln('failed to create an IPV6 socket with error ',socketerror,'. trying to create an IPV4 one instead');}
413      addr := '0.0.0.0';      addr := '0.0.0.0';
414      fdhandlein := socket(PF_INET,socktype,0);      fdhandlein := socket(PF_INET,socktype,0);
415    end;    end;
# Line 750  Line 754 
754    converttov4(binip);    converttov4(binip);
755  end;  end;
756    
757  function tlsocket.getXaddr:string;  function tlsocket.getXaddr:thostname;
758  var  var
759    biniptemp:tbinip;    biniptemp:tbinip;
760  begin  begin
# Line 759  Line 763 
763    if result = '' then result := 'error';    if result = '' then result := 'error';
764  end;  end;
765    
766  function tlsocket.getpeeraddr:string;  function tlsocket.getpeeraddr:thostname;
767  var  var
768    biniptemp:tbinip;    biniptemp:tbinip;
769  begin  begin
# Line 768  Line 772 
772    if result = '' then result := 'error';    if result = '' then result := 'error';
773  end;  end;
774    
775  function tlsocket.getXport:string;  function tlsocket.getXport:ansistring;
776  var  var
777    addr:tinetsockaddrv;    addr:tinetsockaddrv;
778    i:integer;    i:integer;
# Line 784  Line 788 
788    result := inttostr(htons(addr.InAddr.port));    result := inttostr(htons(addr.InAddr.port));
789  end;  end;
790    
791  function tlsocket.getpeerport:string;  function tlsocket.getpeerport:ansistring;
792  var  var
793    addr:tinetsockaddrv;    addr:tinetsockaddrv;
794    i:integer;    i:integer;

Legend:
Removed from v.75  
changed lines
  Added in v.79

No admin address has been configured">No admin address has been configured
ViewVC Help
Powered by ViewVC 1.1.22