<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Aug 29, 2013 at 8:11 AM, Schneider <span dir="ltr"><<a href="mailto:js@globe.de" target="_blank">js@globe.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi List,<br>
<br>
I tried playing around with  a baby example of a server, just printing the data it receives.  But I don't get any output:<br>
<br>
the Code:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
-module(mini_web_srv).<br>
<br>
-export([start/0,send/0]).<br>
<br>
start() -><br>
    { ok, Listen } = gen_tcp:listen(8080,<br>
                   [binary,<br>
                    {packet, 4},<br></blockquote></blockquote><div><br></div><div><snip></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">send_data(Data) -><br>
    {ok, Send} = gen_tcp:connect("localhost", 8080,[binary, {packet, 0} ]),<br>
    gen_tcp:send(Send, Data). <br>
</blockquote>
</blockquote></div><br></div><div class="gmail_extra"><div>It fails because you open the server with {packet,4} and the client with {packet,0}. The client and server must agree on the packet value for them to be able to communicate successfully. To make it work you can either remove the packet option entirely from both client and server, or set the client to {packet,4} to match the server.</div>
<div><br></div><div>You might want to look at <a href="https://gist.github.com/vinoski/4996859">https://gist.github.com/vinoski/4996859</a> to see an example of a very small yet operational web server.</div><div><br></div>
<div>--steve</div><div><br></div></div></div>