Changeset 13 for trunk/SunriseChatNetworkCoreUnit.pas
- Timestamp:
- Feb 11, 2008, 2:14:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SunriseChatNetworkCoreUnit.pas
r11 r13 80 80 81 81 uses 82 IpHlpApi, IpTypes ;82 IpHlpApi, IpTypes, Dialogs, UProtocolMessageLog; 83 83 84 84 procedure Register; … … 137 137 if Sender.Socket.InBufferSize > 0 then begin 138 138 Data := Sender.Socket.ReadAvailable; 139 ProtocolMessageLogForm.Memo1.Lines.Add('TCPClientDataAvailable: ' + Data); 139 140 if Pos(#13, Data) > 0 then begin 140 141 repeat … … 151 152 var 152 153 Text: string; 154 I: Integer; 153 155 begin 154 156 if Sender.Socket.InBufferSize > 0 then begin 155 157 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); 156 161 if BroadcastType = btGlobal then 157 162 fndUDPClientSocket1.Broadcast(IntToStr(UDPPort), Text) else … … 166 171 Address : TSockAddr; 167 172 I: Integer; 168 LocalIPs: TInAddrArray; 169 begin 173 begin 174 ProtocolMessageLogForm.Memo1.Lines.Add('UDBClientDataAvailable: ' + Text); 170 175 if FConnected then begin 171 176 Sender.ReadPacket(Text, Address); 172 for I := 0 to fndTCPServer1.ClientCount -1 do177 for I := 0 to fndTCPServer1.ClientCount - 1 do 173 178 with fndTCPServer1.Client[I] do Socket.SendStr(Text); 174 179 end; … … 192 197 var 193 198 I, II: Integer; 194 Status: Cardinal;195 199 AdaptersList : array of IP_ADAPTER_INFO; 196 200 BufSize: Cardinal; … … 218 222 // Windows NT/2000/XP/Vista 219 223 BufSize := 0; 220 Status :=GetAdaptersInfo(@AdaptersList[0], BufSize);224 GetAdaptersInfo(@AdaptersList[0], BufSize); 221 225 SetLength(AdaptersList, BufSize div SizeOf(IP_ADAPTER_INFO)); 222 Status :=GetAdaptersInfo(@AdaptersList[0], BufSize);226 GetAdaptersInfo(@AdaptersList[0], BufSize); 223 227 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); 235 243 end; 236 NetworkInterfaces.Add(NewNetworkInterface);237 244 end; 238 245 end else begin
Note:
See TracChangeset
for help on using the changeset viewer.