<?xml version='1.0' encoding="utf-8"?>
      <rss version='2.0'>
      <channel>
      <title>Форум на Исходниках.RU</title>
      <link>https://forum.sources.ru</link>
      <description>Форум на Исходниках.RU</description>
      <generator>Форум на Исходниках.RU</generator>
  	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=258121</guid>
        <pubDate>Fri, 05 Dec 2003 12:16:52 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=258121</link>
        <description><![CDATA[varvar:  1) winsock2 file not found  <!--emo&&lt;_&lt;--><img src='http://forum.sources.ru/html/emoticons/dry.gif' border='0' style='vertical-align:middle' alt='dry.gif' /><!--endemo--> <br>2) SOCK_RAW я так понимаю, под гостём в 2000 работать не будет <!--emo&:(--><img src='http://forum.sources.ru/html/emoticons/sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /><!--endemo-->   ]]></description>
        <author>varvar</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=257782</guid>
        <pubDate>Thu, 04 Dec 2003 21:29:14 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=257782</link>
        <description><![CDATA[Борис:  Лови.<br>program S_Ping;<br>{&#036;APPTYPE CONSOLE}<br>uses<br>  windows,<br>  winsock2;<br><br>const<br>       ICMP_ECHO       = 8;<br>       ICMP_ECHOREPLY  = 0;<br>       ICMP_MIN        = 8; // minimum 8 byte icmp packet (just header)<br>       STATUS_FAILED   = &#036;FFFF;<br>       DEF_PACKET_SIZE = 32;<br>       MAX_PACKET      = 1024;<br><br>type<br><br>//  IP header<br>PIpHeader=^TIpHeader;<br>TIpHeader = packed record<br>        VerLen         : byte;<br> tos            : byte;     // Type of service<br>    total_len      : word;     // total length of the packet<br> ident          : word;     // unique identifier<br> frag_and_flags : word;     // flags<br> ttl            : byte;<br> proto          : byte;     // protocol (TCP, UDP etc)<br> checksum       : word;     // IP checksum<br> sourceIP       : DWORD;<br> destIP         : DWORD;<br> end;<br><br>// ICMP header<br>PIcmpHeader=^TIcmpHeader;<br>TIcmpHeader = packed record<br>    i_type    : byte;<br>    i_code    : byte;   // 0 * type sub code */<br>    i_cksum   : word;  //0<br>    i_id      : word;<br>    i_seq     : word;<br> // This is not the std header, but we reserve space for time<br>    timestamp : DWORD;<br> end;<br><br>HDR=packed record<br>IP:TIPHeader;<br>Icmp:PICMPHEADER;<br>end;<br><br>var<br>   wsaData        : TWSADATA;<br>   Dest, From     : TSockAddrIn;<br>   Timeout        : integer;<br>   FromLen        : integer = SizeOf(From);<br>   Dest_Ip   : pointer  = nil;<br>   ICMP_Data : pointer  = nil;<br>   RecvBuf   : pointer  = nil;<br>   hp        : PHostEnt = nil;<br>   Addr   : DWORD  = 0;<br>   Seq_No : Word = 0;<br>   sockRaw : TSOCKET;<br>   BRead, Bwrote ,DataSize : integer;<br>   error:integer;<br>   Head:HDR;<br><br>procedure fill_icmp_data(icmp_data:pchar; datasize:integer);<br>var<br> IcmpHeader:PIcmpHeader;<br> datapart:pointer;<br>begin<br> IcmpHeader := PIcmpHeader(icmp_data);<br> IcmpHeader^.i_type := ICMP_ECHO;<br> IcmpHeader^.i_code := 0;<br> IcmpHeader^.i_id := word(GetCurrentProcessId());<br> IcmpHeader^.i_cksum := 0;<br> IcmpHeader^.i_seq := 0;<br> datapart := icmp_data + sizeof(TIcmpHeader);<br> FillMemory(datapart, datasize - sizeof(TIcmpHeader),ord(&#39;W&#39;));<br>end;<br><br>function  checksum( buffer:pword; size: integer):word;<br>var<br>   cksum : DWORD;<br>begin<br>cksum:=0;<br> while( size &gt; 1 ) do<br> begin<br>cksum:=cksum + buffer^;<br>       buffer:=pword(integer(buffer) + sizeof(word));<br>size :=size-sizeof(word);<br> end;<br> if(size&lt;&gt;0 ) then<br>cksum := cksum + buffer^;<br> cksum := (cksum shr 16) + (cksum and &#036;ffff);<br>result:= word(not(cksum + (cksum shr 16)));<br>end;<br><br>procedure decode_resp(buf:pchar;bytes:integer ;var from:TSockAddrIn);<br>var<br>IpHeader:PIpHeader;<br>IcmpHeader:PIcmpHeader;<br>iphdrlen:word;<br>begin<br>IpHeader := PIpHeader(buf);<br>iphdrlen := (IpHeader^.VerLen and &#036;0F ) * 4 ; // number of 32-bit words *4 = bytes<br>if (bytes  &lt; iphdrlen + ICMP_MIN) then<br>       begin<br>       writeln(&#39;Too few bytes from &#39;,inet_ntoa(from.sin_addr));<br>end;<br>IcmpHeader := PIcmpHeader(integer(buf) + iphdrlen);<br>if (IcmpHeader^.i_type &lt;&gt; ICMP_ECHOREPLY) then<br>       begin<br>     writeln(&#39;non-echo type %d recvd&#39;,IcmpHeader^.i_type);<br>            exit;<br>end;<br>if IcmpHeader^.i_id &lt;&gt; word(GetCurrentProcessId()) then<br>       begin<br>       writeln(&#39;someone else&#39;&#39;s packet&#33;&#39;);<br>          exit;<br>end;<br>write(Bytes,&#39; bytes from &#39;, inet_ntoa(From.sin_addr));<br>write(&#39; icmp_seq = &#39;,IcmpHeader^.i_seq);<br>writeln(&#39; time: &#39;,GetTickCount()-IcmpHeader^.timestamp,&#39; ms &#39;);<br><br>end;<br><br>begin<br><br>TimeOut:=1000;<br>    if (WSAStartup(&#036;0002,wsaData) &lt;&gt; 0)then<br>     begin<br>          writeln(&#39;WSAStartup failed: &#39;,GetLastError());<br>   ExitProcess(STATUS_FAILED);<br>     end;<br>    SockRaw := WSASocket(AF_INET, SOCK_RAW,IPPROTO_ICMP, NIL, 0,WSA_FLAG_OVERLAPPED);<br>    if (sockRaw = INVALID_SOCKET) then<br>    begin<br>          writeln(&#39;WSASocket() failed: &#39;,WSAGetLastError());<br>   ExitProcess(STATUS_FAILED);<br>    end;<br>    Bread :=  setsockopt(SockRaw,SOL_SOCKET,SO_RCVTIMEO ,<br>    pchar(@Timeout),sizeof(Timeout));<br>    if(Bread &lt;&gt; 0) then<br>    begin<br>         writeln(&#39;failed to set recv timeout: &#39;,WSAGetLastError());<br>   ExitProcess(STATUS_FAILED);<br>    end;<br>   Bread :=  setsockopt(SockRaw,SOL_SOCKET,SO_SNDTIMEO,pchar(@Timeout),sizeof(Timeout));<br>    if(Bread &lt;&gt; 0) then<br>    begin<br>         writeln(&#39;failed to set send timeout: &#39;,WSAGetLastError());<br>  ExitProcess(STATUS_FAILED);<br>    end;<br><br><br>    ZeroMemory(@Dest,sizeof(Dest));<br>    hp := gethostbyname(PChar(&#39;127.0.0.1&#39;));<br>    Error := GetLastError();<br>    if (Error &lt;&gt; 0) then<br>    begin<br>       writeln(&#39;Error in call to gethostbyname().Error code: &#39;,Error);<br>    end;<br>    if (hp = nil ) then Addr := inet_addr(PChar(ParamStr(1)));<br>    if ((hp = nil) and (Addr = INADDR_NONE) ) then<br>    begin<br>         writeln(&#39;Unable to resolve &#39;,ParamStr(1));<br>  ExitProcess(STATUS_FAILED);<br>    end;<br>   if (hp &lt;&gt; NIL) then Dest.sin_addr := PInAddr(hp^.h_addr_list^)^<br>       else  Dest.sin_addr.s_addr := Addr;<br>   if (hp &lt;&gt; NIL) then Dest.sin_family := hp^.h_addrtype<br>       else Dest.sin_family := AF_INET;<br>   Dest_ip := inet_ntoa(dest.sin_addr);<br><br>   writeln(&#39;Pinging &#39; +  hp^.h_name+&#39; [&#39;+ inet_ntoa(dest.sin_addr)+&#39;] &#39;);<br><br>  datasize := DEF_PACKET_SIZE;<br><br>  datasize := datasize+sizeof(TIcmpHeader);<br><br>  GetMem( Icmp_Data, MAX_PACKET);<br>  GetMem(RecvBuf,MAX_PACKET);<br>  if (Icmp_Data = nil) or (RecvBuf = nil) then<br>  begin<br>writeln(&#39;GetMem failed&#39;);<br>ExitProcess(STATUS_FAILED);<br>  end;<br><br> ZeroMemory(icmp_data,MAX_PACKET);<br> ZeroMemory(recvbuf,MAX_PACKET);<br><br> fill_icmp_data(Icmp_Data,DataSize);<br><br>   while(True) do<br>   begin<br>PIcmpHeader(Icmp_Data)^.i_cksum := 0;<br>PIcmpHeader(Icmp_Data)^.timestamp := GetTickCount();<br>PIcmpHeader(Icmp_Data)^.i_seq := Seq_no;<br>       inc(Seq_no);<br>PIcmpHeader(Icmp_Data)^.i_cksum := checksum(Icmp_Data,DataSize);<br><br>{head.Icmp:=PIcmpHeader(ICMP_DATA);<br>head.IP.VerLen:=4;<br>head.IP.tos:=0;<br>head.IP.frag_and_flags:=0;<br>head.IP.ttl:=255;<br>head.IP.proto:=IPPROTO_ICMP;<br>head.IP.destIP:=Inet_addr(&#39;127.0.0.1&#39;);<br>head.IP.sourceIP:=Inet_Addr(&#39;137.0.0.1&#39;);<br>DataSize:=DataSize+sizeof(head.IP);<br>}<br><br>Bwrote := sendto(SockRaw,icmp_data^,DataSize,0,Dest, sizeof(Dest));<br>if (Bwrote = SOCKET_ERROR)then<br>       begin<br>  if (WSAGetLastError() = WSAETIMEDOUT) then<br>            begin<br>       writeln(&#39;timed out&#39;);<br> continue;<br>         end;<br>  writeln(&#39;sendto failed: &#39;,WSAGetLastError());<br>  ExitProcess(STATUS_FAILED);<br>end;<br>if (Bwrote &lt; DataSize ) then<br>       begin<br>  writeln(&#39;Wrote &#39;,Bwrote, &#39; bytes&#39;);<br>end;<br>Bread :=  recvfrom(SockRaw,RecvBuf^,MAX_PACKET,0,TSOCKADDRIN(From),FromLen);<br>if (Bread = SOCKET_ERROR)then<br>       begin<br>  if (WSAGetLastError() = WSAETIMEDOUT) then<br>       begin<br>   writeln(&#39;timed out&#39;);<br> continue;<br>       end;<br>  writeln(&#39;recvfrom failed: &#39;,WSAGetLastError());<br>  ExitProcess(STATUS_FAILED);<br>end;<br>decode_resp(RecvBuf,Bread,From);<br>  Sleep(500);<br> end;<br><br> WSACleanUp;<br> FreeMem(RecvBuf);<br> FreeMem(ICMP_Data);<br>end.<br><br><br> ]]></description>
        <author>Борис</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185160</guid>
        <pubDate>Wed, 05 Nov 2003 11:35:16 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185160</link>
        <description><![CDATA[varvar: Пасибо конечно, но нельзя ли это на АПИ сделать, а то я меня из-за этих компанентов и так проект разбух дальше некуда. ??? &nbsp;]]></description>
        <author>varvar</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185159</guid>
        <pubDate>Wed, 05 Nov 2003 08:47:07 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185159</link>
        <description><![CDATA[Mischka: Пользуй IdICMPClient. У него есть Timeout, который можно в мс задавать.]]></description>
        <author>Mischka</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185158</guid>
        <pubDate>Tue, 04 Nov 2003 11:44:08 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185158</link>
        <description><![CDATA[varvar: В примере приведенном здесь http://www.sources.ru/delphi/delphi_ping.shtml один не работающий хост секунд 15 пингуется.]]></description>
        <author>varvar</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185157</guid>
        <pubDate>Tue, 04 Nov 2003 03:03:34 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185157</link>
        <description><![CDATA[Mischka: а нафига асинхронно?<br>150 компов пингуется за несколько секунд...]]></description>
        <author>Mischka</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185156</guid>
        <pubDate>Mon, 03 Nov 2003 13:18:57 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=185156</link>
        <description><![CDATA[varvar: Подскажите плс. как можно посылать ассинхроонные ICMP-пакеты. Мне надо пропинговать несколько адресов(около 150-ти).]]></description>
        <author>varvar</author>
        <category>Delphi: Общие вопросы</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37984</guid>
        <pubDate>Wed, 05 Nov 2003 11:35:16 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37984</link>
        <description><![CDATA[varvar: Пасибо конечно, но нельзя ли это на АПИ сделать, а то я меня из-за этих компанентов и так проект разбух дальше некуда. ??? &nbsp;]]></description>
        <author>varvar</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37981</guid>
        <pubDate>Wed, 05 Nov 2003 08:47:07 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37981</link>
        <description><![CDATA[Mischka: Пользуй IdICMPClient. У него есть Timeout, который можно в мс задавать.]]></description>
        <author>Mischka</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37977</guid>
        <pubDate>Tue, 04 Nov 2003 11:44:08 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37977</link>
        <description><![CDATA[varvar: В примере приведенном здесь http://www.sources.ru/delphi/delphi_ping.shtml один не работающий хост секунд 15 пингуется.]]></description>
        <author>varvar</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37975</guid>
        <pubDate>Tue, 04 Nov 2003 03:03:34 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37975</link>
        <description><![CDATA[Mischka: а нафига асинхронно?<br>150 компов пингуется за несколько секунд...]]></description>
        <author>Mischka</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      <item>
        <guid isPermaLink='true'>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37972</guid>
        <pubDate>Mon, 03 Nov 2003 13:18:57 +0000</pubDate>
        <title>ассинхронные ICMP</title>
        <link>https://forum.sources.ru/index.php?showtopic=2438&amp;view=findpost&amp;p=37972</link>
        <description><![CDATA[varvar: Подскажите плс. как можно посылать ассинхроонные ICMP-пакеты. Мне надо пропинговать несколько адресов(около 150-ти).]]></description>
        <author>varvar</author>
        <category>Delphi: Сетевое программирование</category>
      </item>
	
      </channel>
      </rss>
	