<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    于 2011/3/31 15:04, Joe Armstrong 写道:
    <blockquote
      cite="mid:AANLkTi=H6kOZM6ObDMzFN2_6Y10CG=qr4eiaLfPtxvwP@mail.gmail.com"
      type="cite"><br>
      <br>
      <div class="gmail_quote">On Tue, Mar 29, 2011 at 5:45 AM, zhangbo
        <span dir="ltr"><<a moz-do-not-send="true"
            href="mailto:bo.zhang86@gmail.com">bo.zhang86@gmail.com</a>></span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          Hi,<br>
                 Code:<br>
                 {ok, Listen} = gen_tcp:listen(80, [{packet,0},<br>
                                                 binary,<br>
                                                 {active, true}])<br>
          <br>
                 Loop:<br>
                         receive<br>
                                 {tcp, S, Bin} -><br>
                                         ...<br>
          <br>
          I want to know, when a client send a message("helloworld") to
          server, then send another message("helloworld2"). How many
          messages will the server receive? (I guess 2.)  If the client
          send very fast, or the message is big enough, how the
          situation again?<br>
          <br>
          When receive {tcp, S, Bin}, Bin stands for a message or maybe
          just a fragment of message? If the client send "hello,
          server", Bin maybe "hello, server", but If the message is very
          big, what will Bin be? and how many times will the loop
          receive?<br>
        </blockquote>
        <div><br>
          because you have said {packet,0} then data might become
          fragmented. The options {packet,2}, (or {packet,4} mean "send
          a 2(4) byte length header at the start of the data". If the
          client and server<br>
          both open a socket with {packet,4} then any fragmentation will
          be taken care of by the tcp driver. In this<br>
          case any packet fragments will be recombined by the driver and
          only completed messages delivered to<br>
          the application.<br>
          <br>
          /Joe<br>
           <br>
          <br>
           </div>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <br>
          <br>
          <br>
          _______________________________________________<br>
          erlang-questions mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
          <a moz-do-not-send="true"
            href="http://erlang.org/mailman/listinfo/erlang-questions"
            target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
erlang-questions mailing list
<a class="moz-txt-link-abbreviated" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a>
<a class="moz-txt-link-freetext" href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a>
</pre>
    </blockquote>
    Joe:<br>
    nice!<br>
    thanks<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Best Regards
余超  YuChao  <a class="moz-txt-link-abbreviated" href="mailto:UC:yuchao86@sina.cn">UC:yuchao86@sina.cn</a>
产品研发部 公共服务平台
电话:(8610)62676661
手机:13466539920 <a class="moz-txt-link-abbreviated" href="mailto:MSN:yuchao86@live.cn">MSN:yuchao86@live.cn</a>
地址:北京市海淀区北四环西路58号理想国际大厦15层22-2
___________________________________________
<a class="moz-txt-link-freetext" href="http://www.sina.com.cn">http://www.sina.com.cn</a>     You're the one
   新浪.北京                 一切由你开始</pre>
  </body>
</html>