Strange 'receive' from socket.

Alex Arnon alex.arnon@REDACTED
Mon May 16 13:08:04 CEST 2005


Oh, I hadn't noticed that!! Thank you!

On 5/16/05, Vlad Dumitrescu XX (LN/EAB) <vlad.xx.dumitrescu@REDACTED> wrote:
> Hi,
> 
> Looking at this output,
> 
> 31> client_test:go("10.10.10.8", 19, 3).
> Opened #Port<0.144>
> #Port<0.144> [unknown] :
> {tcp,#Port<0.143>,<<53,54,55,56,...,123,124,125,126,32>>}
> ok
> 
> we can see that the opened socket is #Port<0.144>, while the received message is from #Port<0.143>. Thus the behaviour is corect, since the message isn't from the right socket.
> 
> I interpret this as being the result of running several tests in the same receiver process, and the previous socket did have some data already sent when it was closed. So the message was already in the receiver process' queue, where it was picked by the next run.
> 
> In order to not get this effect, you can either call go in a separate process, or flush the message queue between runs.
> 
> flush() ->
>         receive
>                 _ ->
>                         flush()
>         after 0 ->
>                 ok
>         end.
> 
> best regards,
> Vlad
> 
>



More information about the erlang-questions mailing list