[erlang-questions] inet setoptions after receive data

Erik Søe Sørensen <>
Fri Mar 6 08:11:43 CET 2015


Switching between packet formats *is* possible (we do it sometimes) *but*
you should be aware of interactions with the 'active' socket option.
That is,
- don't use active=true when doing this. Race conditions!
- active=once can be used, but should be off at the point where you change
packetization.
- Finally, for good measure, don't change 'packet' and 'active' in the same
setopts call.

/Erik
Den 04/03/2015 16.45 skrev "Pedro Marques da Silva" <>:

> Hi,
>
> I have looked before I post the question and is not clear why this will
> happen.
>
> Maybe is not possible to switch from {packet,0} to {packet,4} after
> receiving data on a socket!
>
> Best
>
> pms
>
>
>
>
> --
> Pedro Marques da Silva
> ---------------------------------------------------
> E-mail Pessoal : 
> ---------------------------------------------------
>
> 2015-03-04 11:25 GMT+00:00 Rad Gruchalski <>:
>
>>  Hi Pedro,
>>
>> You should have a look at inet:setopts
>> http://www.erlang.org/doc/man/inet.html#setopts-2
>>
>>  Kind regards,
>> Radek Gruchalski
>>  <>
>> de.linkedin.com/in/radgruchalski/
>>
>>
>> *Confidentiality:*This communication is intended for the above-named
>> person and may be confidential and/or legally privileged.
>> If it has come to you in error you must take no action based on it, nor
>> must you copy or show it to anyone; please delete/destroy and inform the
>> sender immediately.
>>
>> On Wednesday, 4 March 2015 at 01:48, Pedro Marques da Silva wrote:
>>
>> Hi Erlangers,
>>
>> I am doing a server to serve a flash application. When a flash client
>> establish a connection(tcp socket) it sends a policy request (xml format
>> message) and the server must reply with a policy file (xml file). After
>> this exchange the client can connect to the socket as a regular connection.
>>
>>
>> When I accept the connection the socket have a {packet,0} option set and
>> checks if is a policy request and sends the policy file back. After this I
>> change the option to {packet,4} but I do not receive anymore data. If I
>> stay with {packet,0} I will receive the binary data sent by the client
>>
>>
>> Any one knows about any problem with changing socket options after
>> receive some data?
>>
>> thanks
>> --
>> Pedro Marques da Silva
>> ---------------------------------------------------
>> E-mail Pessoal : 
>> ---------------------------------------------------
>>  _______________________________________________
>> erlang-questions mailing list
>> 
>> http://erlang.org/mailman/listinfo/erlang-questions
>>
>>
>>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150306/c43ac6e2/attachment.html>


More information about the erlang-questions mailing list