change in behaviour on android

the following code:

fn processLoop() !void {
    try util.print("new Thread started..\n", .{});

    const io = util.io_global;
    const addr: net.IpAddress = .{.ip4 = .unspecified(port)};
    var serv = try addr.listen(io, .{.reuse_address = true});
    defer serv.deinit(io);


    // protocol: base64len*base64*

    while (true) {
        var connection = try serv.accept(io);
        defer connection.close(io);

        var size_buf: [4096]u8 = undefined;
        var size: usize = undefined;


        while(true){
            var stream_reader = connection.reader(io, &size_buf);
            const a = stream_reader.interface.takeDelimiter('*') catch break;
            if (a) |msg| {
                size = try std.fmt.parseInt(usize, msg, 10);
                try util.print("size: {d}\n",.{size});
                read_buf_size = size;
                break;
            } else break;

        }
        try util.print("after first while\n",.{});



        var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
        defer arena.deinit();

        const read_buf = try arena.allocator().alloc(u8, read_buf_size + 1);
        try util.print("after readbuf alloc\n",.{});

        while (true) {
            try util.print("in second while\n",.{});

            var stream_reader = connection.reader(io, read_buf);
            const a = stream_reader.interface.takeDelimiter('*') catch |err| {
                try util.print("ERROR: {}\n", .{err});
                break;
            };
            try util.print("after second delimiter\n",.{});
            try util.print("\n read buffer: {any} \n", .{read_buf});

            if (a) |msg| {
                try util.print("\n message: {s} \n", .{msg});
                try processMessage(msg);
                try util.print("\n Lua Script Exec End \n", .{});
            } else break;
        }
    }

}

works perfectly fine on windows but on android it doesnt enter the last if statement as ‘a’ is null. the client basically sends something like this:

    try writer.interface.writeAll(base64len+'*');
    try writer.interface.writeAll(base64+'*');

i am sorry for my buggy/weird code what might be the problem here? is it timing issue?