<html>
  <head>
    <meta content="text/html; charset=ISO-8859-2"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <div class="moz-cite-prefix">Je to jen priklad co jsem nasel a zda
      se mi sympaticky jednoduchy, tyto namety samozrejme zohlednim,
      diky ;-)<br>
      <br>
      Dne 21. 4. 2013 12:33, Marek Sembol napsal(a):<br>
    </div>
    <blockquote
cite="mid:CADUfZ8H0s895Hb5p8+fdc7p6s1Bv1omAoY73P_s8gOMqRxe+AA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Respektive - podival jsem se do dokumentace na
        ReceiveFrom a ten port 0 je zda se OK, ale musite si ten socket
        nabidnovat pomoci Bind
        <div>Marek</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">
          2013/4/21 Marek Sembol <span dir="ltr">&lt;<a
              moz-do-not-send="true" href="mailto:hwm.land@gmail.com"
              target="_blank">hwm.land@gmail.com</a>&gt;</span><br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Tak jen tak na prvni pohled:
              <div>a) ten prvni new Byte[1024] je zbytecny, ten Encoding
                si naalokuje sam (nepodstatny detail)</div>
              <div>b) jste si naprosto jisty, ze bude fungovat
                ReceiveFrom s portem 0? Mne se to moc nezda (ale hadat
                se nebudu).</div>
              <span class="HOEnZb"><font color="#888888">
                  <div><br>
                  </div>
                  <div>Marek</div>
                </font></span></div>
            <div class="HOEnZb">
              <div class="h5">
                <div class="gmail_extra"><br>
                  <br>
                  <div class="gmail_quote">2013/4/21 Jaroslav Buchta <span
                      dir="ltr">&lt;<a moz-do-not-send="true"
                        href="mailto:jaroslav.buchta@hascomp.cz"
                        target="_blank">jaroslav.buchta@hascomp.cz</a>&gt;</span><br>
                    <blockquote class="gmail_quote" style="margin:0 0 0
                      .8ex;border-left:1px #ccc solid;padding-left:1ex">
                      <div text="#000000" bgcolor="#FFFFFF">
                        <div>No funguje to divne... Jeste me napada,
                          jestli za to nahodou nemuzou Win8...
                          Kazdopadne po odeslani bajtu to prijima, po
                          nejake dobe ne, pak poslu prikaz - odpoved
                          neprijme a po dalsim prikazu uz odpoved
                          prijme. Kdyz to zkousim z Hercules terminalu,
                          tak to funguje jak z praku. Navic na pouziti
                          UdpClient snad neni co zkazit, proste new
                          UdpClient(lokalni port), a pak by IMHO hned
                          melo fungovat Receive a ono prd. Ani v ruznych
                          variantach, kdy v konstruktoru pouziju
                          EndPoint s Ipaddress.Any atd.<br>
                          <br>
                          Kdyz bych pouzil primo Socket treba podle
                          tohoto prikladu, je tam nejaky zadrhel?  (ted
                          nejsem na compu kde bych to mohl zkusit,
                          protoze popijim pivo na zahrade ;-) )<br>
                          <br>
                          <font color="#ffffff">  </font><font
                            color="#000000">{</font><br>
                          <font color="#ffffff">      </font><font
                            color="#7f0055"><b>byte</b></font><font
                            color="#000000">[] </font><font
                            color="#000000">data = </font><font
                            color="#7f0055"><b>new </b></font><font
                            color="#7f0055"><b>byte</b></font><font
                            color="#000000">[</font><font
                            color="#990000">1024</font><font
                            color="#000000">]</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#000000">string input, stringData;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#000000">IPEndPoint ip = </font><font
                            color="#7f0055"><b>new </b></font><font
                            color="#000000">IPEndPoint</font><font
                            color="#000000">(</font><font
                            color="#000000">IPAddress.Parse</font><font
                            color="#000000">(</font><font
                            color="#2a00ff">"127.0.0.1"</font><font
                            color="#000000">)</font><font
                            color="#000000">, </font><font
                            color="#990000">9999</font><font
                            color="#000000">)</font><font
                            color="#000000">;</font><br>
                          <br>
                          <font color="#ffffff">      </font><font
                            color="#000000">Socket server = </font><font
                            color="#7f0055"><b>new </b></font><font
                            color="#000000">Socket</font><font
                            color="#000000">(</font><font
                            color="#000000">AddressFamily.InterNetwork,SocketType.Dgram, ProtocolType.Udp</font><font
                            color="#000000">)</font><font
                            color="#000000">;</font><br>
                          <br>
                          <font color="#ffffff">      </font><font
                            color="#000000">string welcome = </font><font
                            color="#2a00ff">"Hello"</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#000000">data = Encoding.ASCII.GetBytes</font><font
                            color="#000000">(</font><font
                            color="#000000">welcome</font><font
                            color="#000000">)</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#000000">server.SendTo</font><font
                            color="#000000">(</font><font
                            color="#000000">data, data.Length, SocketFlags.None, ip</font><font
                            color="#000000">)</font><font
                            color="#000000">;</font><br>
                          <br>
                          <font color="#ffffff">      </font><font
                            color="#000000">IPEndPoint sender = </font><font
                            color="#7f0055"><b>new </b></font><font
                            color="#000000">IPEndPoint</font><font
                            color="#000000">(</font><font
                            color="#000000">IPAddress.Any, </font><font
                            color="#990000">0</font><font
                            color="#000000">)</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#000000">EndPoint Remote = </font><font
                            color="#000000">(</font><font
                            color="#000000">EndPoint</font><font
                            color="#000000">)</font><font
                            color="#000000">sender;</font><br>
                          <br>
                          <font color="#ffffff">      </font><font
                            color="#000000">data = </font><font
                            color="#7f0055"><b>new </b></font><font
                            color="#7f0055"><b>byte</b></font><font
                            color="#000000">[</font><font
                            color="#990000">1024</font><font
                            color="#000000">]</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#7f0055"><b>int </b></font><font
                            color="#000000">receivedDataLength = server.ReceiveFrom</font><font
                            color="#000000">(</font><font
                            color="#000000">data, ref Remote</font><font
                            color="#000000">)</font><font
                            color="#000000">;</font><br>
                          <br>
                          <font color="#ffffff">      </font><font
                            color="#000000">Console.WriteLine</font><font
                            color="#000000">(</font><font
                            color="#2a00ff">"Message received from {0}:"</font><font
                            color="#000000">, Remote.ToString</font><font
                            color="#000000">())</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">      </font><font
                            color="#000000">Console.WriteLine</font><font
                            color="#000000">(</font><font
                            color="#000000">Encoding.ASCII.GetString</font><font
                            color="#000000">(</font><font
                            color="#000000">data, </font><font
                            color="#990000">0</font><font
                            color="#000000">, receivedDataLength</font><font
                            color="#000000">))</font><font
                            color="#000000">;</font><br>
                          <br>
                          <font color="#ffffff">      </font><font
                            color="#000000">server.Close</font><font
                            color="#000000">()</font><font
                            color="#000000">;</font><br>
                          <font color="#ffffff">   </font><font
                            color="#000000">}</font><br>
                          <br>
                          Vypada to jednoduse a premyslim, v cem je
                          zadrhel. Myslim, ze vzhledem k pozadavku na
                          vetsi objemy dat, cim na nizsi level pujdu,
                          tim lip... A se siti jsem v .NET jeste
                          nedelal.<br>
                          <br>
                          Dne 21. 4. 2013 10:39, Marek Sembol napsal(a):<br>
                        </div>
                        <div>
                          <div>
                            <blockquote type="cite">
                              <div dir="ltr">no mne to chovani prijde
                                minimalne hodne zvlastni a asi bych
                                intenzivne hledal chybu u sebe. Pripadne
                                bych opustil UdpClient a pracoval primo
                                se Socket. Ale fakt si myslim, ze za to
                                .NET nemuze. Podle mne trida Socket
                                pouze zabali WinAPI a UdpClient
                                "zjednodusi" pouzivani Socket (spolu se
                                specializaci na UDP a radou omezeni)
                                <div> Marek</div>
                              </div>
                              <div class="gmail_extra"><br>
                                <br>
                                <div class="gmail_quote">2013/4/21
                                  Jaroslav Buchta <span dir="ltr">&lt;<a
                                      moz-do-not-send="true"
                                      href="mailto:jaroslav.buchta@hascomp.cz"
                                      target="_blank">jaroslav.buchta@hascomp.cz</a>&gt;</span><br>
                                  <blockquote class="gmail_quote"
                                    style="margin:0 0 0
                                    .8ex;border-left:1px #ccc
                                    solid;padding-left:1ex">
                                    <div text="#000000"
                                      bgcolor="#FFFFFF">
                                      <div>Ajo vidite, Close, to me
                                        nenapadlo ;-) Zkusim. Ale stejne
                                        to casem asi udelam ve Win API,
                                        kdyz s tim polem bytu nebude
                                        problem.<br>
                                        <br>
                                        Dne 21. 4. 2013 10:12, Marek
                                        Sembol napsal(a):<br>
                                      </div>
                                      <div>
                                        <div>
                                          <blockquote type="cite">
                                            <div dir="ltr">vyjadrim se
                                              jen castecne:)
                                              <div>Pokud pri tom volani
                                                z C# -&gt; WinAPI ty
                                                "velke objemy dat" jsou
                                                Byte[], tak ta konverze
                                                je prakticky zadarmo. </div>
                                              <div>.NET si to pole
                                                proste jen prispendli v
                                                pameti a preda dal
                                                ukazatel.</div>
                                              <div><br>
                                              </div>
                                              <div>Synchronni vs.
                                                asynchronni - no tady se
                                                to asi nebude chovat
                                                rozdilne. Ono to
                                                synchronni volani byva
                                                proste jen par volani
                                                BeginAsyncXXX a
                                                EndAsyncXXX.</div>
                                              <div><br>
                                              </div>
                                              <div> Aplikace se
                                                samozrejme ukoncit da.
                                                Staci treba zavrit ten
                                                socket a volani prijmu
                                                skonci na vyjimku (a tu
                                                je mozno osetrit, ze).
                                                Moznosti jak ten socket
                                                zavrit je cela rada.
                                                Jako rekce na CTRL-C
                                                (pri konzolove
                                                aplikaci), jako reakci
                                                na service-stop (pri
                                                service), jako volani
                                                naschedulovane pomoci
                                                timeru (kdykoliv) a
                                                podobne.</div>
                                              <div><br>
                                              </div>
                                              <div>Marek</div>
                                            </div>
                                            <div class="gmail_extra"><br>
                                              <br>
                                              <div class="gmail_quote">2013/4/21
                                                Jaroslav Buchta <span
                                                  dir="ltr">&lt;<a
                                                    moz-do-not-send="true"
href="mailto:jaroslav.buchta@hascomp.cz" target="_blank">jaroslav.buchta@hascomp.cz</a>&gt;</span><br>
                                                <blockquote
                                                  class="gmail_quote"
                                                  style="margin:0 0 0
                                                  .8ex;border-left:1px
                                                  #ccc
                                                  solid;padding-left:1ex">Diky
                                                  za namety, zarizeni
                                                  zda se funguje docela
                                                  zpusobne, co nefunguje
                                                  podle predstav je
                                                  trida .NET UdpClient
                                                  na PC - proste pokud
                                                  neodeslu aspon bajt na
                                                  zarizeni, nic neprijme
                                                  a i potom za nejaky
                                                  timeout chcipne a
                                                  pomuze az odeslani
                                                  dalsiho byte aby zase
                                                  bylo neco prijmuto -
                                                  nic jineho takze port
                                                  atd. je asi nasteveno
                                                  spravne... Neni nejaka
                                                  option, kterou jsem
                                                  zatim nepostrehnul,
                                                  aby to fungovalo
                                                  primitivne a jen
                                                  cekalo, az na port
                                                  neco prijde??? Zkousel
                                                  jsem uz vsechny mozne
                                                  varianty synchronni
                                                  (tam je vtipne, ze
                                                  Receive nema zadny
                                                  timeout a aplikace se
                                                  nakonec ani neda
                                                  ukoncit...) i
                                                  asynchronni. C# je
                                                  dobre asi fakt jen na
                                                  GUI...<br>
                                                  <br>
                                                  Co zatim hledam, tak
                                                  jsou s touto tridou
                                                  jen problemy - je jina
                                                  cesta nez pouzit DLL
                                                  kde to bude
                                                  realizovano jako
                                                  WinAPI (coz by snad
                                                  mohlo fungovat...)
                                                  Zase konverze velkych
                                                  objemu dat do C# pak
                                                  bude asi narocna na
                                                  rezii...<br>
                                                  <br>
                                                  <br>
                                                  <br>
                                                  <br>
                                                  Dne 21. 4. 2013 9:35,
                                                  Ondrej napsal(a):
                                                  <div>
                                                    <div><br>
                                                      <blockquote
                                                        class="gmail_quote"
                                                        style="margin:0
                                                        0 0
                                                        .8ex;border-left:1px
                                                        #ccc
                                                        solid;padding-left:1ex">
                                                        Někde v
                                                        lwipopts.h jde
                                                        nastavit max.
                                                        velikost paketu.
                                                        1400B je
                                                        velikost paketu
                                                        (náhoda :-) -
                                                        takže by se
                                                        někde měla ještě
                                                        povolit
                                                        fragmentace. Ale
                                                        100% jistý si
                                                        tím nejsem.
                                                        Nicméně zrovna
                                                        ST má pěkné PDF
                                                        s návodem na
                                                        lwip. Byly tam
                                                        myslím i nějaké
                                                        testy rychlosti.<br>
                                                        <br>
                                                        Add: ztrácení
                                                        paketů:
                                                        Nainstalujte si
                                                        Wireshark a
                                                        zkontrolujte,
                                                        jestli jsou
                                                        pakety tam. To
                                                        je naprostý
                                                        základ. Je
                                                        docela slušná
                                                        šance, že ST
                                                        odesílat stíhá a
                                                        nestíhá přijímat
                                                        jen program. Ono
                                                        obecně odeslat
                                                        UDP paket není
                                                        problém a to i
                                                        na velkých
                                                        rychlostech.
                                                        Obvykle je
                                                        problém pak data
                                                        napřijímat (ať
                                                        už v PC nebo na
                                                        uP).<br>
                                                        <br>
                                                        Jinak UDP
                                                        fragmentace
                                                        smysl má a to
                                                        velký. Pro velké
                                                        toky je problém
                                                        přijímat 1400B
                                                        pakety, ale
                                                        pokud je
                                                        fragmentuje
                                                        třeba na 14000B
                                                        (10x větší), tak
                                                        u to může PC
                                                        stíhat. Už jen
                                                        třeba protože
                                                        "callback"
                                                        fce./přerušení
                                                        se bude volat
                                                        10x méně často.<br>
                                                        <br>
                                                        Ondřej<br>
                                                        <br>
                                                        Dne 20.4.2013
                                                        22:54, Jaroslav
                                                        Buchta
                                                        napsal(a):<br>
                                                        <blockquote
                                                          class="gmail_quote"
                                                          style="margin:0
                                                          0 0
                                                          .8ex;border-left:1px
                                                          #ccc
                                                          solid;padding-left:1ex">
                                                          Mate nekdo
                                                          zkusenost jak
                                                          na to? Jednak
                                                          jsem zjistil,
                                                          ze je nekde
                                                          omezena
                                                          velikost UDP
                                                          paketu proste
                                                          tak, ze pri
                                                          prekroceni to
                                                          poskodi haldu
                                                          a cele to jde
                                                          do kytek,
                                                          hranice je
                                                          nekde kolem
                                                          1400B<br>
                                                          Dal je
                                                          zajimave, ze
                                                          kdyz odesilam
                                                          pakety
                                                          bezprostredne
                                                          za sebou,
                                                          ztraceji se
                                                          (ale az od
                                                          nejakeho poctu
                                                          a zalezi na
                                                          delce) a kdyz
                                                          treba ted za
                                                          kazdy 4.
                                                          vlozim pauzu
                                                          1ms tak to
                                                          funguje OK
                                                          (cili rychlost
                                                          4MB/s
                                                          stabilne, coz
                                                          mi prijde OK,
                                                          samozrejme
                                                          prime
                                                          pripojeni do
                                                          pocitace)<br>
                                                          Otazkou je,
                                                          jestli se
                                                          pakety ztraci
                                                          u STM nebo na
                                                          strane PC...
                                                          Ale na PC je
                                                          gigabit, to by
                                                          snad melo byt
                                                          slusne
                                                          dimenzovane.<br>
                                                          Dalsi zahada
                                                          je u C# s
                                                          UdpClient,
                                                          dokud aspon
                                                          bajt nevyslu,
                                                          nic neprijmu
                                                          (i kdyz data
                                                          na port
                                                          prokazatelne
                                                          chodi, overeno
                                                          hercules
                                                          terminalem).
                                                          To jsem v
                                                          dokumentaci
                                                          nikde nenasel,
                                                          melo by to
                                                          snad fungovat
                                                          pro prijem bez
                                                          volani Connect
                                                          a Send, ne?<br>
                                                          <br>
                                                          Jinak teda s
                                                          rychlosti
                                                          spokojenost,
                                                          mozna by to
                                                          slo i o chlup
                                                          vyse,
                                                          prilezitostne
                                                          vyzkousim.
                                                          Taky by asi
                                                          pomohlo zvysit
                                                          delku paketu -
                                                          vi nekdo jak
                                                          na to?
                                                          Pochopil jsem,
                                                          ze jsou ruzne
                                                          metody alokace
                                                          pameti v LwIP.<br>
_______________________________________________<br>
                                                          HW-list
                                                          mailing list
                                                           -  sponsored
                                                          by <a
                                                          moz-do-not-send="true"
href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
                                                          <a
                                                          moz-do-not-send="true"
href="mailto:Hw-list@list.hw.cz" target="_blank">Hw-list@list.hw.cz</a><br>
                                                          <a
                                                          moz-do-not-send="true"
href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
                                                          <br>
                                                        </blockquote>
                                                        <br>
_______________________________________________<br>
                                                        HW-list mailing
                                                        list  -
                                                         sponsored by <a
moz-do-not-send="true" href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
                                                        <a
                                                          moz-do-not-send="true"
href="mailto:Hw-list@list.hw.cz" target="_blank">Hw-list@list.hw.cz</a><br>
                                                        <a
                                                          moz-do-not-send="true"
href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
                                                      </blockquote>
                                                      <br>
_______________________________________________<br>
                                                      HW-list mailing
                                                      list  -  sponsored
                                                      by <a
                                                        moz-do-not-send="true"
href="http://www.HW.cz" target="_blank">www.HW.cz</a><br>
                                                      <a
                                                        moz-do-not-send="true"
href="mailto:Hw-list@list.hw.cz" target="_blank">Hw-list@list.hw.cz</a><br>
                                                      <a
                                                        moz-do-not-send="true"
href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
                                                    </div>
                                                  </div>
                                                </blockquote>
                                              </div>
                                              <br>
                                            </div>
                                            <br>
                                            <fieldset></fieldset>
                                            <br>
                                            <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a moz-do-not-send="true" href="http://www.HW.cz" target="_blank">www.HW.cz</a>
<a moz-do-not-send="true" href="mailto:Hw-list@list.hw.cz" target="_blank">Hw-list@list.hw.cz</a>
<a moz-do-not-send="true" href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
                                          </blockquote>
                                          <br>
                                        </div>
                                      </div>
                                    </div>
                                    <br>
_______________________________________________<br>
                                    HW-list mailing list  -  sponsored
                                    by <a moz-do-not-send="true"
                                      href="http://www.HW.cz"
                                      target="_blank">www.HW.cz</a><br>
                                    <a moz-do-not-send="true"
                                      href="mailto:Hw-list@list.hw.cz"
                                      target="_blank">Hw-list@list.hw.cz</a><br>
                                    <a moz-do-not-send="true"
                                      href="http://list.hw.cz/mailman/listinfo/hw-list"
                                      target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
                                    <br>
                                  </blockquote>
                                </div>
                                <br>
                              </div>
                              <br>
                              <fieldset></fieldset>
                              <br>
                              <pre>_______________________________________________
HW-list mailing list  -  sponsored by <a moz-do-not-send="true" href="http://www.HW.cz" target="_blank">www.HW.cz</a>
<a moz-do-not-send="true" href="mailto:Hw-list@list.hw.cz" target="_blank">Hw-list@list.hw.cz</a>
<a moz-do-not-send="true" href="http://list.hw.cz/mailman/listinfo/hw-list" target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
                            </blockquote>
                            <br>
                          </div>
                        </div>
                      </div>
                      <br>
                      _______________________________________________<br>
                      HW-list mailing list  -  sponsored by <a
                        moz-do-not-send="true" href="http://www.HW.cz"
                        target="_blank">www.HW.cz</a><br>
                      <a moz-do-not-send="true"
                        href="mailto:Hw-list@list.hw.cz" target="_blank">Hw-list@list.hw.cz</a><br>
                      <a moz-do-not-send="true"
                        href="http://list.hw.cz/mailman/listinfo/hw-list"
                        target="_blank">http://list.hw.cz/mailman/listinfo/hw-list</a><br>
                      <br>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
HW-list mailing list  -  sponsored by <a class="moz-txt-link-abbreviated" href="http://www.HW.cz">www.HW.cz</a>
<a class="moz-txt-link-abbreviated" href="mailto:Hw-list@list.hw.cz">Hw-list@list.hw.cz</a>
<a class="moz-txt-link-freetext" href="http://list.hw.cz/mailman/listinfo/hw-list">http://list.hw.cz/mailman/listinfo/hw-list</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>