diff --git a/anubis_dev/library/system/muscle.anubis b/anubis_dev/library/system/muscle.anubis index 3309f8a..2922747 100644 --- a/anubis_dev/library/system/muscle.anubis +++ b/anubis_dev/library/system/muscle.anubis @@ -1564,21 +1564,36 @@ public define Message_Send_Result ok(socket) then //the necessary UDP socket was created, hence we send the Message packet with header = host_to_lendian_Int32_ByteArray(length(buffer)) + - host_to_lendian_Int32_ByteArray(_MUSCLE_MESSAGE_ENCODING_DEFAULT), - //send the header. that header is construct as follow (size of the following message + header mark) + host_to_lendian_Int32_ByteArray(_MUSCLE_MESSAGE_ENCODING_DEFAULT) + + buffer, + //send the header + buffer. that header is construct as follow (size of the following message + header mark) if udp_send(socket, ip_address, ip_port, header) is { network_unreachable then network_error, - packet_sent then - //now we send the real message - if udp_send(socket, ip_address, ip_port, buffer) is - { - network_unreachable then network_error, - packet_sent then ok - } + packet_sent then ok } } }. + +public define Maybe(Message) + receive_message_from_io + ( + Data_IO io + ) = + if read_Int32(io) is + { + failure then print("Can't read data \n"); failure, + success(data_len) then + if read_Int32(io) is + { + failure then print("Can't read data \n"); failure, + success(encoding) then + if encoding = _MUSCLE_MESSAGE_ENCODING_DEFAULT then + unflatten_message(io) + else print("Bad header or unknown encoding:" + encoding); failure + } + }. + public define Maybe(Int32) send_buffer -- libgit2 0.21.4