Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protocol_func( Parent, Sock, Buffer ) ->
- receive
- {tcp, Sock, Data} ->
- Data1 = <<Buffer/binary, Data/binary>>,
- <<Length:32/little-signed, Data2/binary>> = Data1,
- ActualLength = byte_size(Data2),
- if
- ActualLength > Length ->
- Parent ! decode_packet( binary:part( Data2, 0, Length - 1 ) ),
- protocol_func( Parent, Sock, binary:part( Data2, Length, ActualLength - Length ) );
- ActualLength == Length ->
- Parent ! decode_packet( Data2 ),
- protocol_func( Parent, Sock, <<>> );
- ActualLength < Length ->
- protocol_func( Parent, Sock, Data2 )
- end;
- {send_packet_data, From, Data } ->
- From ! send( Sock, Data )
- end.
Add Comment
Please, Sign In to add comment