Ignore:
Timestamp:
Feb 11, 2008, 2:14:42 PM (17 years ago)
Author:
george
Message:

Opraveno: Načítání seznamu síťových adaptérů na Linuxu.
Přidáno: Úpravy pro potřeby ladění problému s nepřijímáním UDP paketů.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SunriseChatNetworkCoreUnit.pas

    r11 r13  
    8080
    8181uses
    82   IpHlpApi, IpTypes;
     82  IpHlpApi, IpTypes, Dialogs, UProtocolMessageLog;
    8383
    8484procedure Register;
     
    137137  if Sender.Socket.InBufferSize > 0 then begin
    138138    Data := Sender.Socket.ReadAvailable;
     139    ProtocolMessageLogForm.Memo1.Lines.Add('TCPClientDataAvailable: ' + Data);
    139140    if Pos(#13, Data) > 0 then begin
    140141      repeat
     
    151152var
    152153  Text: string;
     154  I: Integer;
    153155begin
    154156  if Sender.Socket.InBufferSize > 0 then begin
    155157    Text := Sender.Socket.ReadAvailable;
     158    for I := 0 to fndTCPServer1.ClientCount - 1 do
     159      fndTCPServer1.Client[I].Socket.SendStr(Text);
     160    ProtocolMessageLogForm.Memo1.Lines.Add('TCPServerDataAvailable: ' + Text);
    156161    if BroadcastType = btGlobal then
    157162      fndUDPClientSocket1.Broadcast(IntToStr(UDPPort), Text) else
     
    166171  Address : TSockAddr;
    167172  I: Integer;
    168   LocalIPs: TInAddrArray;
    169 begin
     173begin
     174  ProtocolMessageLogForm.Memo1.Lines.Add('UDBClientDataAvailable: ' + Text);
    170175  if FConnected then begin
    171176    Sender.ReadPacket(Text, Address);
    172     for I := 0 to fndTCPServer1.ClientCount-1 do
     177    for I := 0 to fndTCPServer1.ClientCount - 1 do
    173178      with fndTCPServer1.Client[I] do Socket.SendStr(Text);
    174179  end;
     
    192197var
    193198  I, II: Integer;
    194   Status: Cardinal;
    195199  AdaptersList : array of IP_ADAPTER_INFO;
    196200  BufSize: Cardinal;
     
    218222    // Windows NT/2000/XP/Vista
    219223    BufSize := 0;
    220     Status := GetAdaptersInfo(@AdaptersList[0], BufSize);
     224    GetAdaptersInfo(@AdaptersList[0], BufSize);
    221225    SetLength(AdaptersList, BufSize div SizeOf(IP_ADAPTER_INFO));
    222     Status := GetAdaptersInfo(@AdaptersList[0], BufSize);
     226    GetAdaptersInfo(@AdaptersList[0], BufSize);
    223227    for I := 0 to High(AdaptersList) do with AdaptersList[I] do begin
    224       NewNetworkInterface := TNetworkInterface.Create(Self);
    225       with NewNetworkInterface do begin
    226         IPAddress := IpAddressList.IPAddress.S;
    227         SubNetMask := IpAddressList.IPMask.s;
    228         GUID := AdapterName;
    229         Name := Description;
    230         SubnetParts := Explode('.', SubNetMask);
    231         IPParts := Explode('.', IPAddress);
    232         for II := 0 to 3 do
    233           IPParts[II] := IntToStr(StrToInt(IPParts[II]) or (StrToInt(SubnetParts[II]) xor $ff));
    234         BroadcastIPAddress := IPParts[0]+'.'+IPParts[1]+'.'+IPParts[2]+'.'+IPParts[3];
     228      if IpAddressList.IPAddress.S <> '' then begin
     229        NewNetworkInterface := TNetworkInterface.Create(Self);
     230        with NewNetworkInterface do begin
     231          IPAddress := IpAddressList.IPAddress.S;
     232          SubNetMask := IpAddressList.IPMask.s;
     233          GUID := AdapterName;
     234          Name := Description;
     235          if Name = '' then Name := 'Network adapter ' + IntToStr(I);
     236          SubnetParts := Explode('.', SubNetMask);
     237          IPParts := Explode('.', IPAddress);
     238          for II := 0 to 3 do
     239            IPParts[II] := IntToStr(StrToInt(IPParts[II]) or (StrToInt(SubnetParts[II]) xor $ff));
     240          BroadcastIPAddress := IPParts[0]+'.'+IPParts[1]+'.'+IPParts[2]+'.'+IPParts[3];
     241        end;
     242        NetworkInterfaces.Add(NewNetworkInterface);
    235243      end;
    236       NetworkInterfaces.Add(NewNetworkInterface);
    237244    end;
    238245  end else begin
Note: See TracChangeset for help on using the changeset viewer.